Skip to content
Snippets Groups Projects
Commit 14c75418 authored by Manuel Herrmann's avatar Manuel Herrmann
Browse files

docker-compose files for testing

parent 4f080419
No related branches found
No related tags found
No related merge requests found
# Docker Environment Setup
## Setup And Using The Environment
### Step 1
Ensure database dump path inside docker-compose.yml points to the newest dump
### Step 2
Change database connection inside
registration-system/config.local.php
from "localhost" to "db"
### Step 3
Build and start up the containers
```
docker-compose build
docker-compose up -d
```
### Step 4
Wait for containers to start up.
Open http://localhost:8080 in your browser
## Cleanup
Run:
```
docker-compose stop
docker-compose rm
```
Then remove mysql_data folder
web:
image: richarvey/nginx-php-fpm
links:
- db:db
ports:
- "8080:80"
volumes:
- ./registration-system:/usr/share/nginx/html
db:
build: docker
dockerfile: DockerfileMariaDB
environment:
- MYSQL_DATABASE=fsfahrt
- MYSQL_USER=fsfahrt
- MYSQL_PASSWORD=9Lug*96q
expose:
- "3306"
volumes:
- ./mysql_data:/var/lib/mysql
- ./registration-system/other/sqlDumps/update_20151004.sql:/dump.sql:ro
FROM ubuntu:latest
MAINTAINER Dennis Micky Jensen <root@mewm.org>
# Download MariaDB
RUN apt-get update && \
apt-get install -y mariadb-server pwgen && \
rm -rf /var/lib/mysql/* && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Set bind address to 0.0.0.0 and enforce port
RUN sed -i -r 's/bind-address.*$/bind-address = 0.0.0.0/' /etc/mysql/my.cnf
#RUN sed -i -r 's/port.*$/port = 3306'/ /etc/mysql/my.cnf
# Add bash scripts for creating a user and run server
ADD create-mariadb-user.sh /create-mariadb-user.sh
ADD run-mariadb.sh /run-mariadb.sh
RUN chmod 775 /*.sh
# To avoid mysql whining about this variable
ENV TERM dumb
EXPOSE "3306"
# Set default entry point
CMD ["/run-mariadb.sh"]
See http://blog.mewm.org/ghost-mariadb-with-docker-fig/
#!/bin/bash
/usr/bin/mysqld_safe > /dev/null 2>&1 &
RET=1
while [[ RET -ne 0 ]]; do
sleep 5
mysql -uroot -e "status" > /dev/null 2>&1
RET=$?
done
mysql -uroot -e "CREATE USER '$MYSQL_USER'@'%' IDENTIFIED BY '$MYSQL_PASSWORD'"
mysql -uroot -e "GRANT ALL PRIVILEGES ON *.* TO '$MYSQL_USER'@'%' WITH GRANT OPTION"
mysql -uroot -e "CREATE DATABASE $MYSQL_DATABASE"
mysql -uroot $MYSQL_DATABASE < /dump.sql
mysqladmin -uroot shutdown
#!/bin/bash
VOLUME_HOME="/var/lib/mysql"
if find ${VOLUME_HOME} -maxdepth 0 -empty | read v; then
echo " -> Installation detected in $VOLUME_HOME"
echo " -> Installing MariaDB"
mysql_install_db > /dev/null 2>&1
echo " -> Done!"
/create-mariadb-user.sh
else
echo "-> Booting on existing volume!"
fi
exec mysqld_safe
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment