mirror of
https://github.com/tim-krehan/shopping-list.git
synced 2024-11-23 14:20:41 +01:00
create docker image
This commit is contained in:
parent
b5cebdadfb
commit
d61a89e767
1739 changed files with 244 additions and 53 deletions
4
.env
Normal file
4
.env
Normal file
|
@ -0,0 +1,4 @@
|
|||
MYSQL_DATABASEHOST=mysql
|
||||
MYSQL_DATABASENAME=shoppinglist
|
||||
MYSQL_DATABASEUSER=shoppinguser
|
||||
MYSQL_DATABASEPASSWORD=databasepassword.keepsecret!!
|
|
@ -1,9 +0,0 @@
|
|||
stages:
|
||||
- test
|
||||
|
||||
check_code:
|
||||
stage: test
|
||||
script:
|
||||
- ./.test/php_syntax.sh
|
||||
tags:
|
||||
- php
|
|
@ -1,28 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
PHP=/usr/bin/php
|
||||
|
||||
COUNT=0
|
||||
HIT=0
|
||||
|
||||
cd ..
|
||||
|
||||
for file in `find . -name \*.php`; do
|
||||
OUTPUT=`$PHP -l $file`
|
||||
if ! [ 0 = $? ]; then
|
||||
echo $OUTPUT
|
||||
HIT=$(($HIT+1))
|
||||
fi
|
||||
COUNT=$(($COUNT+1))
|
||||
done
|
||||
|
||||
|
||||
if ! [ 0 = $HIT ]; then
|
||||
echo "Syntax check: FAILED"
|
||||
echo "Checked Files: $COUNT, Files with Errors: $HIT"
|
||||
exit 1
|
||||
else
|
||||
echo "Syntax check: PASSED"
|
||||
echo "Checked Files: $COUNT"
|
||||
exit 0
|
||||
fi
|
17
.vscode/tasks.json
vendored
Normal file
17
.vscode/tasks.json
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||
// for the documentation about the tasks.json format
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "build and run",
|
||||
"type": "shell",
|
||||
"command": "docker-compose up --build",
|
||||
"problemMatcher": [],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
6
apache/Dockerfile
Normal file
6
apache/Dockerfile
Normal file
|
@ -0,0 +1,6 @@
|
|||
FROM httpd:2.4.33-alpine
|
||||
RUN apk update;
|
||||
RUN apk upgrade;
|
||||
COPY shoppinglist.conf /usr/local/apache2/conf/shoppinglist.conf
|
||||
|
||||
RUN echo "Include /usr/local/apache2/conf/shoppinglist.conf" >> /usr/local/apache2/conf/httpd.conf
|
22
apache/shoppinglist.conf
Normal file
22
apache/shoppinglist.conf
Normal file
|
@ -0,0 +1,22 @@
|
|||
ServerName localhost
|
||||
|
||||
LoadModule deflate_module /usr/local/apache2/modules/mod_deflate.so
|
||||
LoadModule rewrite_module /usr/local/apache2/modules/mod_rewrite.so
|
||||
LoadModule proxy_module /usr/local/apache2/modules/mod_proxy.so
|
||||
LoadModule proxy_fcgi_module /usr/local/apache2/modules/mod_proxy_fcgi.so
|
||||
|
||||
<VirtualHost *:80>
|
||||
# Proxy .php requests to port 9000 of the php-fpm container
|
||||
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://php:9000/var/www/html/$1
|
||||
DocumentRoot /var/www/html/
|
||||
<Directory /var/www/html/>
|
||||
DirectoryIndex index.php
|
||||
Options Indexes FollowSymLinks
|
||||
AllowOverride All
|
||||
Require all granted
|
||||
</Directory>
|
||||
|
||||
# Send apache logs to stdout and stderr
|
||||
CustomLog /proc/self/fd/1 common
|
||||
ErrorLog /proc/self/fd/2
|
||||
</VirtualHost>
|
|
@ -1,6 +0,0 @@
|
|||
<?php
|
||||
$CONFIG = array (
|
||||
'installed' => false,
|
||||
);
|
||||
|
||||
?>
|
45
docker-compose.yml
Normal file
45
docker-compose.yml
Normal file
|
@ -0,0 +1,45 @@
|
|||
version: "3.2"
|
||||
services:
|
||||
php:
|
||||
build: './php/'
|
||||
env_file:
|
||||
- .env
|
||||
networks:
|
||||
- backend
|
||||
volumes:
|
||||
- ./public_html/:/var/www/html/
|
||||
apache:
|
||||
build: './apache/'
|
||||
depends_on:
|
||||
- php
|
||||
- mysql
|
||||
networks:
|
||||
- frontend
|
||||
- backend
|
||||
ports:
|
||||
- "8080:80"
|
||||
volumes:
|
||||
- ./public_html/:/var/www/html/
|
||||
mysql:
|
||||
build: "./mysql/"
|
||||
networks:
|
||||
- backend
|
||||
command: [
|
||||
"--default-authentication-plugin=mysql_native_password",
|
||||
"--character-set-server=utf8",
|
||||
"--collation-server=utf8_general_ci"
|
||||
]
|
||||
environment:
|
||||
- MYSQL_DATABASE=${MYSQL_DATABASENAME}
|
||||
- MYSQL_USER=${MYSQL_DATABASEUSER}
|
||||
- MYSQL_PASSWORD=${MYSQL_DATABASEPASSWORD}
|
||||
- MYSQL_RANDOM_ROOT_PASSWORD=true
|
||||
- TZ=Europe/Berlin
|
||||
- LANG=C.UTF-8
|
||||
volumes:
|
||||
- mysql-data:/var/lib/mysql
|
||||
networks:
|
||||
frontend:
|
||||
backend:
|
||||
volumes:
|
||||
mysql-data:
|
3
mysql/Dockerfile
Normal file
3
mysql/Dockerfile
Normal file
|
@ -0,0 +1,3 @@
|
|||
FROM mysql
|
||||
|
||||
ADD ./schema.sql /docker-entrypoint-initdb.d/
|
120
mysql/schema.sql
Normal file
120
mysql/schema.sql
Normal file
|
@ -0,0 +1,120 @@
|
|||
|
||||
CREATE TABLE `Einheit` (
|
||||
`ID` int(11) NOT NULL,
|
||||
`Name` varchar(255) NOT NULL,
|
||||
`Standard` tinyint(1) NOT NULL
|
||||
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE `Einkauf` (
|
||||
`ID` int(11) NOT NULL,
|
||||
`Anzahl` double NOT NULL DEFAULT '1',
|
||||
`Einheit` int(11) NOT NULL DEFAULT '5',
|
||||
`Name` varchar(255) NOT NULL,
|
||||
`Erledigt` tinyint(1) NOT NULL DEFAULT '0'
|
||||
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE `users` (
|
||||
`uid` INT NOT NULL,
|
||||
`username` varchar(32) NOT NULL,
|
||||
`email` varchar(128),
|
||||
`theme` varchar(128) NULL,
|
||||
`password` char(128) NOT NULL,
|
||||
`salt` char(64) NOT NULL,
|
||||
`last_login` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE `sessions` (
|
||||
`session_id` varchar(255),
|
||||
`user` INT NOT NULL,
|
||||
`expires` datetime NOT NULL
|
||||
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE `Rezept` (
|
||||
`ID` int(11) NOT NULL,
|
||||
`Name` varchar(255) NOT NULL,
|
||||
`Dauer` int(11) NOT NULL,
|
||||
`Beschreibung` longtext NOT NULL
|
||||
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE `RezeptZutat` (
|
||||
`ID` int(11) NOT NULL,
|
||||
`Rezept` int(11) NOT NULL,
|
||||
`Menge` float NOT NULL,
|
||||
`Einheit` int(11) NOT NULL,
|
||||
`Zutat` int(11) NOT NULL
|
||||
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE `Zutat` (
|
||||
`ID` int(11) NOT NULL,
|
||||
`Name` varchar(255) NOT NULL
|
||||
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
CREATE VIEW `ViewEinkauf` AS select `Einkauf`.`ID` AS `ID`,`Einkauf`.`Anzahl` AS `Anzahl`,`Einheit`.`Name` AS `Einheit`,`Einkauf`.`Name` AS `Name`,`Einkauf`.`Erledigt` AS `Erledigt` from (`Einkauf` join `Einheit` on((`Einkauf`.`Einheit` = `Einheit`.`ID`))) ;
|
||||
|
||||
ALTER TABLE `Einheit`
|
||||
ADD PRIMARY KEY (`ID`);
|
||||
|
||||
ALTER TABLE `Einkauf`
|
||||
ADD PRIMARY KEY (`ID`),
|
||||
ADD KEY `FK_Einheit` (`Einheit`);
|
||||
|
||||
ALTER TABLE `users`
|
||||
ADD PRIMARY KEY (`uid`);
|
||||
|
||||
ALTER TABLE `sessions`
|
||||
ADD PRIMARY KEY (`session_id`);
|
||||
|
||||
ALTER TABLE `Rezept`
|
||||
ADD PRIMARY KEY (`ID`);
|
||||
|
||||
ALTER TABLE `RezeptZutat`
|
||||
ADD PRIMARY KEY (`ID`),
|
||||
ADD KEY `fk_rezeptzutat_rezept` (`Rezept`),
|
||||
ADD KEY `fk_rezeptzutat_einheit` (`Einheit`),
|
||||
ADD KEY `fk_rezeptzutat_zutat` (`Zutat`);
|
||||
|
||||
ALTER TABLE `Zutat`
|
||||
ADD PRIMARY KEY (`ID`);
|
||||
|
||||
ALTER TABLE `Einheit`
|
||||
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
ALTER TABLE `Einkauf`
|
||||
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
ALTER TABLE `Rezept`
|
||||
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
ALTER TABLE `RezeptZutat`
|
||||
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
ALTER TABLE `Zutat`
|
||||
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
ALTER TABLE `users`
|
||||
MODIFY `uid` INT NOT NULL AUTO_INCREMENT,
|
||||
MODIFY `username` varchar(32) NOT NULL UNIQUE;
|
||||
|
||||
ALTER TABLE `sessions`
|
||||
ADD CONSTRAINT `fk_session_uid` FOREIGN KEY (`user`) REFERENCES `users` (`uid`);
|
||||
|
||||
ALTER TABLE `Einkauf`
|
||||
ADD CONSTRAINT `fk_einkauf_einheit` FOREIGN KEY (`Einheit`) REFERENCES `Einheit` (`ID`);
|
||||
|
||||
ALTER TABLE `RezeptZutat`
|
||||
ADD CONSTRAINT `fk_rezeptzutat_einheit` FOREIGN KEY (`Einheit`) REFERENCES `Einheit` (`ID`),
|
||||
ADD CONSTRAINT `fk_rezeptzutat_rezept` FOREIGN KEY (`Rezept`) REFERENCES `Rezept` (`ID`),
|
||||
ADD CONSTRAINT `fk_rezeptzutat_zutat` FOREIGN KEY (`Zutat`) REFERENCES `Zutat` (`ID`);
|
||||
|
||||
INSERT INTO `Einheit` (`ID`, `Name`, `Standard`) VALUES
|
||||
(1, 'g', 0),
|
||||
(2, 'kg', 0),
|
||||
(3, 'ml', 0),
|
||||
(4, 'l', 0),
|
||||
(5, 'x', 1),
|
||||
(6, 'EL', 0),
|
||||
(7, 'TL', 0),
|
||||
(8, 'Prise', 0),
|
||||
(9, 'Dose', 0),
|
||||
(10, 'Packung', 0),
|
||||
(11, 'Glas', 0);
|
4
php/Dockerfile
Normal file
4
php/Dockerfile
Normal file
|
@ -0,0 +1,4 @@
|
|||
FROM php:7.4.27-fpm-alpine3.15
|
||||
RUN apk update;
|
||||
RUN apk upgrade;
|
||||
RUN docker-php-ext-install mysqli
|
0
.gitignore → public_html/.gitignore
vendored
0
.gitignore → public_html/.gitignore
vendored
|
@ -10,8 +10,8 @@ if (!(isset($_SESSION["docroot"]))) {
|
|||
$_SESSION["docroot"] = __DIR__;
|
||||
}
|
||||
include $_SESSION["docroot"] . '/config/config.php';
|
||||
if (($CONFIG["installed"] == false) && ($site != "error")) {
|
||||
header("Location: /install/install.php");
|
||||
if (($CONFIG["first_launch"] == true) && ($site != "error")) {
|
||||
header("Location: /install/install_adduser.php");
|
||||
exit;
|
||||
}
|
||||
if ($site != "error") {
|
||||
|
@ -19,10 +19,11 @@ if ($site != "error") {
|
|||
}
|
||||
|
||||
include $_SESSION["docroot"] . '/version.php';
|
||||
|
||||
include $_SESSION["docroot"] . '/php/classes.user.php';
|
||||
|
||||
$token = isset($_COOKIE["token"]) ? $_COOKIE["token"] : "";
|
||||
$user = new user();
|
||||
$user->get_info($_COOKIE["token"]);
|
||||
$user->get_info($token);
|
||||
?>
|
||||
<html lang="de" dir="ltr">
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
session_start();
|
||||
if (!($_SESSION["docroot"]))
|
||||
if (!isset($_SESSION["docroot"]))
|
||||
{
|
||||
$_SESSION["docroot"] = str_replace("/install", "", __DIR__);
|
||||
}
|
|
@ -1,4 +1,3 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
0
js/jquery.js → public_html/js/jquery.js
vendored
0
js/jquery.js → public_html/js/jquery.js
vendored
|
@ -1,16 +1,17 @@
|
|||
<?php
|
||||
session_start();
|
||||
$_SESSION["docroot"] = __DIR__;
|
||||
switch($_GET["call"]) {
|
||||
case 'list':
|
||||
include $_SESSION["docroot"].'/php/edit-list.php';
|
||||
include $_SESSION["docroot"].'/edit-list.php';
|
||||
break;
|
||||
|
||||
case 'recipes':
|
||||
include $_SESSION["docroot"].'/php/edit-recipes.php';
|
||||
include $_SESSION["docroot"].'/edit-recipes.php';
|
||||
break;
|
||||
|
||||
case 'user':
|
||||
include $_SESSION["docroot"].'/php/edit-user.php';
|
||||
include $_SESSION["docroot"].'/edit-user.php';
|
||||
break;
|
||||
|
||||
default:
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue