WIP: added phpmyadmin, init with database dump
This commit is contained in:
6
homepage/cwsvJudo/participo/.gitignore
vendored
Normal file
6
homepage/cwsvJudo/participo/.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
# don't commit credentials
|
||||||
|
db_root_password.txt
|
||||||
|
db_password.txt
|
||||||
|
# sql dump shall be created new every time (from the productive system)
|
||||||
|
cwsvjudo.sql
|
||||||
|
|
||||||
11
homepage/cwsvJudo/participo/PHP.dockerfile
Normal file
11
homepage/cwsvJudo/participo/PHP.dockerfile
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# select base image
|
||||||
|
FROM php:fpm
|
||||||
|
|
||||||
|
# startup scripts for the image
|
||||||
|
# - docker-php-ext-install -- install helper script from PHP
|
||||||
|
RUN docker-php-ext-install pdo pdo_mysql
|
||||||
|
|
||||||
|
# install and add xdebug extension
|
||||||
|
# @todo What is pecl?
|
||||||
|
# @todo What is xdebug and how do I use it?
|
||||||
|
RUN pecl install xdebug && docker-php-ext-enable xdebug
|
||||||
14
homepage/cwsvJudo/participo/app/public/mysql.php
Normal file
14
homepage/cwsvJudo/participo/app/public/mysql.php
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
# demo file testing the docker installed db
|
||||||
|
$pdo = new PDO(
|
||||||
|
'mysql:dbname=tutorial; host=mysql',
|
||||||
|
'tutorial',
|
||||||
|
'secret',
|
||||||
|
[PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]
|
||||||
|
);
|
||||||
|
|
||||||
|
$query = $pdo->query('SHOW VARIABLES like "version"');
|
||||||
|
|
||||||
|
$row = $query->fetch();
|
||||||
|
|
||||||
|
echo 'MYSQL version: '. $row['Value'];
|
||||||
1
homepage/cwsvJudo/participo/db_password.txt.template
Normal file
1
homepage/cwsvJudo/participo/db_password.txt.template
Normal file
@@ -0,0 +1 @@
|
|||||||
|
insert_MYSQL_PASSWORD_here_and_remove_template_in_filename
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
insert_MYSQL_ROOT_PASSWORD_here_and_remove_template_in_filename
|
||||||
8
homepage/cwsvJudo/participo/docker-clean
Executable file
8
homepage/cwsvJudo/participo/docker-clean
Executable file
@@ -0,0 +1,8 @@
|
|||||||
|
#! /usr/bin/env bash
|
||||||
|
|
||||||
|
# stop all containers
|
||||||
|
docker-compose down --remove-orphans
|
||||||
|
# delete all containers
|
||||||
|
docker rm -f $(docker ps -a -q)
|
||||||
|
# delete all volumes
|
||||||
|
docker volume rm $(docker volume ls -q)
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
# version for the docker compose file to use
|
# version for the docker compose file to use
|
||||||
version: "3"
|
version: "3"
|
||||||
|
|
||||||
# a dict of services running in the container label: {<service>} label is a self defined name for the service
|
# a dict of services running in the container label: {<service>} label is a self defined name for the service
|
||||||
services:
|
services:
|
||||||
# the web service
|
# the webserver service
|
||||||
web:
|
web:
|
||||||
image: nginx:latest
|
image: nginx:latest
|
||||||
# port forwarding
|
# port forwarding
|
||||||
@@ -13,7 +14,60 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- ./nginx.conf:/etc/nginx/conf.d/nginx.conf
|
- ./nginx.conf:/etc/nginx/conf.d/nginx.conf
|
||||||
- ./app:/app
|
- ./app:/app
|
||||||
|
# php and extensions
|
||||||
php:
|
php:
|
||||||
image: php:fpm
|
# use pre-build image from docker..
|
||||||
|
# image: php:fpm
|
||||||
|
# .. or build your own image
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: PHP.dockerfile
|
||||||
|
# files and directories to be available in the container
|
||||||
|
# @todo Except from better structuring: Is there a reason for not having the volumes as one central list?
|
||||||
volumes:
|
volumes:
|
||||||
- ./app:/app
|
- ./app:/app
|
||||||
|
# install a dm
|
||||||
|
# @todo Maybe use postgre instead?
|
||||||
|
database:
|
||||||
|
image: mariadb:latest
|
||||||
|
restart: always
|
||||||
|
# define environment variables
|
||||||
|
# @todo Should credentials be placed here? Even if it is just a test environment
|
||||||
|
environment:
|
||||||
|
MYSQL_USER: 'cwsvjudo'
|
||||||
|
MYSQL_DATABASE: 'cwsvjudo'
|
||||||
|
MYSQL_TCP_PORT: '3306'
|
||||||
|
MYSQL_ROOT_PASSWORD_FILE: /run/secrets/db_root_password
|
||||||
|
MYSQL_PASSWORD_FILE: /run/secrets/db_password
|
||||||
|
volumes:
|
||||||
|
- mysqldata:/var/lib/mysql
|
||||||
|
# initial database
|
||||||
|
# - has to be created first, e.g., by dumping the database from the prooductive system
|
||||||
|
- ./cwsvjudo.sql:/docker-entrypoint-initdb.d/cwsvjudo.sql
|
||||||
|
ports:
|
||||||
|
- 3306:3306
|
||||||
|
secrets:
|
||||||
|
- db_root_password
|
||||||
|
- db_password
|
||||||
|
# phpmyadmin
|
||||||
|
phpmyadmin:
|
||||||
|
image: phpmyadmin:latest
|
||||||
|
restart: always
|
||||||
|
depends_on:
|
||||||
|
- database
|
||||||
|
ports:
|
||||||
|
- 8080:80
|
||||||
|
environment:
|
||||||
|
# name of the host is the name of the db service started above! Why? I don't know!
|
||||||
|
- PMA_HOST=database
|
||||||
|
- PMA_PORT=3306
|
||||||
|
# - PMA_ARBITRARY=1
|
||||||
|
volumes:
|
||||||
|
# data storage for the db
|
||||||
|
mysqldata: {}
|
||||||
|
|
||||||
|
secrets:
|
||||||
|
db_root_password:
|
||||||
|
file: db_root_password.txt
|
||||||
|
db_password:
|
||||||
|
file: db_password.txt
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# @todo Needs helpfull comments.
|
||||||
server {
|
server {
|
||||||
listen 80 default_server;
|
listen 80 default_server;
|
||||||
root /app/public;
|
root /app/public;
|
||||||
|
|||||||
Reference in New Issue
Block a user