dockerized the application for easier distribution and depleyment
This commit is contained in:
parent
b06c3cec3e
commit
a9147c3698
6 changed files with 100 additions and 28 deletions
2
Dockerfile.db
Normal file
2
Dockerfile.db
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
FROM mariadb
|
||||||
|
COPY ./MatheApp.sql /docker-entrypoint-initdb.d/
|
||||||
18
Dockerfile.math_wizard
Normal file
18
Dockerfile.math_wizard
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
# Verwende ein Basisimage mit PHP
|
||||||
|
FROM php:8.2-cli
|
||||||
|
|
||||||
|
# Setze das Arbeitsverzeichnis
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Kopiere den Projektinhalt in das Arbeitsverzeichnis im Container
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Installiere die erforderlichen PHP-Erweiterungen
|
||||||
|
RUN docker-php-ext-install pdo pdo_mysql
|
||||||
|
|
||||||
|
# Exponiere den Port, den der PHP-Server verwenden wird
|
||||||
|
EXPOSE 8080
|
||||||
|
|
||||||
|
# Starte den PHP-Server beim Containerstart
|
||||||
|
CMD ["php", "-S", "0.0.0.0:8080"]
|
||||||
|
|
||||||
43
MatheApp.sql
43
MatheApp.sql
|
|
@ -1,6 +1,6 @@
|
||||||
-- MariaDB dump 10.19 Distrib 10.6.11-MariaDB, for debian-linux-gnu (x86_64)
|
-- MariaDB dump 10.19 Distrib 10.6.11-MariaDB, for debian-linux-gnu (x86_64)
|
||||||
--
|
--
|
||||||
-- Host: localhost Database: MatheApp
|
-- Host: localhost Database: MatheApp
|
||||||
-- ------------------------------------------------------
|
-- ------------------------------------------------------
|
||||||
-- Server version 10.6.11-MariaDB-0ubuntu0.22.04.1
|
-- Server version 10.6.11-MariaDB-0ubuntu0.22.04.1
|
||||||
|
|
||||||
|
|
@ -20,22 +20,22 @@
|
||||||
--
|
--
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `user`;
|
DROP TABLE IF EXISTS `user`;
|
||||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
/*!40101 SET character_set_client = utf8 */;
|
/*!40101 SET character_set_client = utf8 */;
|
||||||
CREATE TABLE `user` (
|
CREATE TABLE `user` (
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
`username` varchar(255) NOT NULL,
|
`username` varchar(255) NOT NULL,
|
||||||
`vorname` varchar(255) NOT NULL,
|
`vorname` varchar(255) NOT NULL,
|
||||||
`nachname` varchar(255) NOT NULL,
|
`nachname` varchar(255) NOT NULL,
|
||||||
`email` varchar(255) NOT NULL,
|
`email` varchar(255) NOT NULL,
|
||||||
`password` varchar(255) NOT NULL,
|
`password` varchar(255) NOT NULL,
|
||||||
`lesson_count` int(11) NOT NULL,
|
`lesson_count` int(11) NOT NULL,
|
||||||
`level` int(11) NOT NULL,
|
`level` int(11) NOT NULL,
|
||||||
`xp` int(11) NOT NULL,
|
`xp` int(11) NOT NULL,
|
||||||
`coins` int(11) NOT NULL,
|
`coins` int(11) NOT NULL,
|
||||||
`isAdmin` tinyint(1) DEFAULT NULL,
|
`isAdmin` tinyint(1) DEFAULT NULL,
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
UNIQUE KEY `reference_unique` (`username`,`email`)
|
UNIQUE KEY `reference_unique` (`username`,`email`)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
|
|
@ -48,14 +48,3 @@ LOCK TABLES `user` WRITE;
|
||||||
INSERT INTO `user` VALUES (3,'patryk','patryk','hegenberg','testMail@test.de','$2y$10$G8s3UA8zMjHnKAQ01B4.R.NX7gLZi28BuQiOVyBbnbYbNCZusx13W',1,3,110,566,NULL),(16,'admin','','','admin@themathwizard.de','$2y$10$M8DKsBn2KA49XCzdUzVY4.hciLBOzgzB94z3YR4hNyNgvwNlnXiyO',0,1,0,0,1);
|
INSERT INTO `user` VALUES (3,'patryk','patryk','hegenberg','testMail@test.de','$2y$10$G8s3UA8zMjHnKAQ01B4.R.NX7gLZi28BuQiOVyBbnbYbNCZusx13W',1,3,110,566,NULL),(16,'admin','','','admin@themathwizard.de','$2y$10$M8DKsBn2KA49XCzdUzVY4.hciLBOzgzB94z3YR4hNyNgvwNlnXiyO',0,1,0,0,1);
|
||||||
/*!40000 ALTER TABLE `user` ENABLE KEYS */;
|
/*!40000 ALTER TABLE `user` ENABLE KEYS */;
|
||||||
UNLOCK TABLES;
|
UNLOCK TABLES;
|
||||||
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
|
|
||||||
|
|
||||||
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
|
||||||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
|
||||||
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
|
|
||||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
|
||||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
|
||||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
|
||||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
|
||||||
|
|
||||||
-- Dump completed on 2023-01-24 21:17:03
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'database' => [
|
'database' => [
|
||||||
'host' => 'localhost',
|
'host' => 'db',
|
||||||
'port' => 3306,
|
'port' => 3306,
|
||||||
'dbname' => 'MatheApp',
|
'dbname' => 'MatheApp',
|
||||||
'charset' => 'utf8mb4'
|
'charset' => 'utf8mb4'
|
||||||
|
|
|
||||||
46
docker-compose.yml
Normal file
46
docker-compose.yml
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
version: '3'
|
||||||
|
|
||||||
|
services:
|
||||||
|
web:
|
||||||
|
#image: math_wizard
|
||||||
|
build:
|
||||||
|
context: /home/pata/dev/WebProg/TheMathWizard
|
||||||
|
dockerfile: Dockerfile.math_wizard
|
||||||
|
ports:
|
||||||
|
- "8080:8080"
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
|
networks:
|
||||||
|
- mathwizard-network
|
||||||
|
|
||||||
|
db:
|
||||||
|
build:
|
||||||
|
context: /home/pata/dev/WebProg/TheMathWizard
|
||||||
|
dockerfile: Dockerfile.db
|
||||||
|
environment:
|
||||||
|
MYSQL_ROOT_PASSWORD: password
|
||||||
|
MYSQL_DATABASE: MatheApp
|
||||||
|
MYSQL_USER: MatheApp
|
||||||
|
MYSQL_PASSWORD: password
|
||||||
|
volumes:
|
||||||
|
- ./math_wizard_db_data:/var/lib/mysql
|
||||||
|
networks:
|
||||||
|
- mathwizard-network
|
||||||
|
|
||||||
|
nginx:
|
||||||
|
image: nginx
|
||||||
|
ports:
|
||||||
|
- "80:80"
|
||||||
|
volumes:
|
||||||
|
- ./nginx.conf:/etc/nginx/nginx.conf:ro
|
||||||
|
depends_on:
|
||||||
|
- web
|
||||||
|
networks:
|
||||||
|
- mathwizard-network
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
math_wizard_db_data:
|
||||||
|
|
||||||
|
networks:
|
||||||
|
mathwizard-network:
|
||||||
|
driver: bridge
|
||||||
17
nginx.conf
Normal file
17
nginx.conf
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
events {}
|
||||||
|
|
||||||
|
http {
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name math-wizard;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://web:8080;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue