Development and production docker configuration
This commit is contained in:
parent
19725ec4e9
commit
2a6188d79d
5 changed files with 132 additions and 26 deletions
10
.env
Normal file
10
.env
Normal 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
|
15
Dockerfile
15
Dockerfile
|
@ -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
34
docker-compose.prod.yml
Normal 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:
|
|
@ -1,23 +1,26 @@
|
||||||
storage:
|
version: '2'
|
||||||
image: 'busybox:latest'
|
services:
|
||||||
volumes:
|
database:
|
||||||
- /var/lib/mysql
|
image: mysql
|
||||||
- ./src:/app
|
|
||||||
command: sleep 3153600000
|
|
||||||
database:
|
|
||||||
image: mysql:5.7
|
|
||||||
environment:
|
environment:
|
||||||
MYSQL_ROOT_PASSWORD: root
|
- MYSQL_ROOT_PASSWORD=veryhardpassword
|
||||||
MYSQL_DATABASE: easyappointments
|
- MYSQL_DATABASE=easyapp
|
||||||
volumes_from:
|
- MYSQL_USER=easyapp
|
||||||
- storage
|
- MYSQL_PASSWORD=veryhardpassword
|
||||||
restart: always
|
|
||||||
mem_limit: 200m
|
application:
|
||||||
app:
|
image: easyappointments
|
||||||
build: ./
|
build:
|
||||||
|
context: .
|
||||||
|
volumes:
|
||||||
|
- ./src:/app
|
||||||
|
command: dev
|
||||||
ports:
|
ports:
|
||||||
- 80:80
|
- ${APP_HOST}:80:80
|
||||||
links:
|
environment:
|
||||||
- database:database
|
- DB_NAME=easyapp
|
||||||
volumes_from:
|
- DB_USERNAME=easyapp
|
||||||
- storage
|
- DB_PASSWORD=veryhardpassword
|
||||||
|
- DB_HOST=database:3306
|
||||||
|
- APP_URL=localhost
|
||||||
|
restart: always
|
50
docker-entrypoint.sh
Normal file
50
docker-entrypoint.sh
Normal 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 $@
|
Loading…
Reference in a new issue