diff --git a/.env b/.env new file mode 100644 index 00000000..6022dd2f --- /dev/null +++ b/.env @@ -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 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 2545f434..786aa408 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,14 @@ -FROM tutum/apache-php +FROM wichon/alpine-apache-php -MAINTAINER Alex Tselegidis +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"] \ No newline at end of file diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml new file mode 100644 index 00000000..6dfe9387 --- /dev/null +++ b/docker-compose.prod.yml @@ -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: \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 7a63f0f1..4f7f8dd7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,23 +1,26 @@ -storage: - image: 'busybox:latest' - volumes: - - /var/lib/mysql - - ./src:/app - command: sleep 3153600000 -database: - image: mysql:5.7 - environment: - MYSQL_ROOT_PASSWORD: root - MYSQL_DATABASE: easyappointments - volumes_from: - - storage - restart: always - mem_limit: 200m -app: - build: ./ - ports: - - 80:80 - links: - - database:database - volumes_from: - - storage +version: '2' +services: + database: + image: mysql + environment: + - MYSQL_ROOT_PASSWORD=veryhardpassword + - MYSQL_DATABASE=easyapp + - MYSQL_USER=easyapp + - MYSQL_PASSWORD=veryhardpassword + + application: + image: easyappointments + build: + context: . + volumes: + - ./src:/app + command: dev + ports: + - ${APP_HOST}:80:80 + environment: + - DB_NAME=easyapp + - DB_USERNAME=easyapp + - DB_PASSWORD=veryhardpassword + - DB_HOST=database:3306 + - APP_URL=localhost + restart: always \ No newline at end of file diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100644 index 00000000..f2c0d9da --- /dev/null +++ b/docker-entrypoint.sh @@ -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\n\tAllowOverride All\n\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\n\tAllowOverride All\n\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 $@ \ No newline at end of file