Development and production docker configuration

This commit is contained in:
Valian 2017-04-21 12:07:45 +02:00
parent 19725ec4e9
commit 2a6188d79d
5 changed files with 132 additions and 26 deletions

10
.env Normal file
View file

@ -0,0 +1,10 @@
DB_USERNAME=easyappointments
DB_NAME=easyappointments
# before deploying to production change to harder password
DB_PASSWORD=change-that-password
# change to you installation address
APP_URL=localhost
APP_HOST=0.0.0.0
APP_PORT=80

View file

@ -1,5 +1,14 @@
FROM tutum/apache-php
FROM wichon/alpine-apache-php
MAINTAINER Alex Tselegidis <alextselegidis@gmail.com>
ENV PROJECT_DIR=/app \
APP_URL=localhost
EXPOSE 80
RUN apk --no-cache add php-zlib php-mysqli php-gettext
COPY ./src $PROJECT_DIR
COPY docker-entrypoint.sh /entrypoint.sh
VOLUME $PROJECT_DIR/storage
ENTRYPOINT ["/bin/sh", "/entrypoint.sh"]
CMD ["run"]

34
docker-compose.prod.yml Normal file
View file

@ -0,0 +1,34 @@
version: '2'
services:
database:
image: mysql
environment:
- MYSQL_ROOT_PASSWORD=${DB_PASSWORD}
- MYSQL_DATABASE=${DB_NAME}
- MYSQL_USER=${DB_USERNAME}
- MYSQL_PASSWORD=${DB_PASSWORD}
volumes:
- easy-appointments-data:/var/lib/mysql
restart: always
application:
image: easyappointments
build:
context: .
ports:
- 80:80
environment:
- DB_NAME=${DB_NAME}
- DB_USERNAME=${DB_USERNAME}
- DB_PASSWORD=${DB_PASSWORD}
- DB_HOST=database:3306
- APP_URL=${APP_URL}
- APP_HOST=${APP_HOST}
volumes:
- easy-appointments-storage:/app/src/storage
restart: always
volumes:
easy-appointments-data:
easy-appointments-storage:

View file

@ -1,23 +1,26 @@
storage:
image: 'busybox:latest'
volumes:
- /var/lib/mysql
- ./src:/app
command: sleep 3153600000
version: '2'
services:
database:
image: mysql:5.7
image: mysql
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: easyappointments
volumes_from:
- storage
restart: always
mem_limit: 200m
app:
build: ./
- MYSQL_ROOT_PASSWORD=veryhardpassword
- MYSQL_DATABASE=easyapp
- MYSQL_USER=easyapp
- MYSQL_PASSWORD=veryhardpassword
application:
image: easyappointments
build:
context: .
volumes:
- ./src:/app
command: dev
ports:
- 80:80
links:
- database:database
volumes_from:
- storage
- ${APP_HOST}:80:80
environment:
- DB_NAME=easyapp
- DB_USERNAME=easyapp
- DB_PASSWORD=veryhardpassword
- DB_HOST=database:3306
- APP_URL=localhost
restart: always

50
docker-entrypoint.sh Normal file
View file

@ -0,0 +1,50 @@
#!/usr/bin/env sh
if [ "$1" == "run" ]; then
echo "Preparing Easy!Appointments production configuration.."
cp $PROJECT_DIR/config-sample.php $PROJECT_DIR/config.php
sed -i "s/DB_HOST = ''/DB_HOST = '$DB_HOST'/g" $PROJECT_DIR/config.php
sed -i "s/DB_USERNAME = ''/DB_USERNAME = '$DB_USERNAME'/g" $PROJECT_DIR/config.php
sed -i "s/DB_PASSWORD = ''/DB_PASSWORD = '$DB_PASSWORD'/g" $PROJECT_DIR/config.php
sed -i "s/DB_NAME = ''/DB_NAME = '$DB_NAME'/g" $PROJECT_DIR/config.php
sed -i "s/url-to-easyappointments-directory/$APP_URL/g" $PROJECT_DIR/config.php
sed -i "s#^DocumentRoot \".*#DocumentRoot \"$PROJECT_DIR\"#g" /etc/apache2/httpd.conf
sed -i "s#/var/www/localhost/htdocs#$PROJECT_DIR#" /etc/apache2/httpd.conf
printf "\n<Directory \"$PROJECT_DIR\">\n\tAllowOverride All\n</Directory>\n" >> /etc/apache2/httpd.conf
chown -R apache:apache $PROJECT_DIR
chmod -R 777 $PROJECT_DIR/storage/uploads
echo "Starting Easy!Appointments server.."
exec httpd -D FOREGROUND
elif [ "$1" == "dev" ]; then
echo "Preparing Easy!Appointments development configuration.."
if [ ! -e "$PROJECT_DIR/config.php" ]; then
cp $PROJECT_DIR/config-sample.php $PROJECT_DIR/config.php
sed -i "s/DB_HOST = ''/DB_HOST = '$DB_HOST'/g" $PROJECT_DIR/config.php
sed -i "s/DB_USERNAME = ''/DB_USERNAME = '$DB_USERNAME'/g" $PROJECT_DIR/config.php
sed -i "s/DB_PASSWORD = ''/DB_PASSWORD = '$DB_PASSWORD'/g" $PROJECT_DIR/config.php
sed -i "s/DB_NAME = ''/DB_NAME = '$DB_NAME'/g" $PROJECT_DIR/config.php
sed -i "s/DEBUG_MODE = FALSE/DEBUG_MODE = TRUE/g" $PROJECT_DIR/config.php
sed -i "s/url-to-easyappointments-directory/$APP_URL/g" $PROJECT_DIR/config.php
fi
sed -i "s#^DocumentRoot \".*#DocumentRoot \"$PROJECT_DIR\"#g" /etc/apache2/httpd.conf
sed -i "s#/var/www/localhost/htdocs#$PROJECT_DIR#" /etc/apache2/httpd.conf
printf "\n<Directory \"$PROJECT_DIR\">\n\tAllowOverride All\n</Directory>\n" >> /etc/apache2/httpd.conf
chown -R apache:apache $PROJECT_DIR
chmod -R 777 $PROJECT_DIR/storage/uploads
echo "Starting Easy!Appointments server.."
exec httpd -D FOREGROUND
fi
exec $@