Add docker compose, add db setup, add webserver dockerfile

This commit is contained in:
Marcel Schwarz 2020-03-14 19:14:26 +01:00
parent b018861b55
commit f2619aeb2c
6 changed files with 41 additions and 10 deletions

2
.gitignore vendored
View File

@ -1,2 +0,0 @@
dbConnect.php

5
Dockerfile Normal file
View File

@ -0,0 +1,5 @@
FROM php:7.0-apache
RUN apt-get update
RUN docker-php-ext-install pdo pdo_mysql mysqli
RUN a2enmod rewrite

View File

@ -1,12 +1,12 @@
<?php
<?php
//Create DB connection.
//This creates a usable "database" - Variable as mysqli Objekt
//simply remove the "~" in front of the filename
$user = 'user';
$password = 'password';
$db = 'database name';
$host = 'ip or domain';
$user = 'root';
$password = 'Test';
$db = 'kd42696_ipr-projekt';
$host = 'db';
$port = 3306;
$database = new mysqli($host, $user, $password, $db, $port);
@ -15,4 +15,4 @@ if ($database->connect_error) {
die('Connect Error (' . $database->connect_errno . ') ' . $database->connect_error);
}
?>
?>

29
docker-compose.yml Normal file
View File

@ -0,0 +1,29 @@
version: '3'
services:
db:
build:
context: ./sql
ports:
- "5455:3306"
volumes:
- "db-data:/var/lib/mysql"
environment:
MYSQL_ROOT_PASSWORD: "Test"
webserver:
build:
context: .
ports:
- "80:80"
volumes:
- "./:/var/www/html"
depends_on:
- db
volumes:
db-data:
# docker run -d -p 5455:3306 -v `pwd`/setup:/docker-entrypoint-initdb.d/ -v `pwd`/mysql-data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=Test mariadb
# docker run -d -p 80:80 --name my-apache-php-app -v `pwd`:/var/www/html php:7.0-apache

View File

@ -1,2 +1,2 @@
FROM mariadb
COPY ./sql-dump.sql /docker-entrypoint-initdb.d/
COPY ./sample-db.sql /docker-entrypoint-initdb.d/

View File

@ -1 +0,0 @@
docker run -d -p 5455:3306 -v `pwd`/setup:/docker-entrypoint-initdb.d/ -v `pwd`/mysql-data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=Test mariadb