diff --git a/.env b/.env index e22bd892..d38b7b00 100644 --- a/.env +++ b/.env @@ -1,10 +1,10 @@ DB_USERNAME=easyapp DB_NAME=easyapp -# before deploying to production change to harder password +# before deploying to production change to harder password, and don't commit it to git DB_PASSWORD=veryhardpassword -# change to you installation address +# change to your installation address APP_URL=localhost APP_HOST=0.0.0.0 APP_PORT=80 diff --git a/Dockerfile b/Dockerfile index a9d9b1d2..4c4b60f5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,14 @@ -FROM wichon/alpine-apache-php +FROM php:7.0-apache -ENV PROJECT_DIR=/app \ +ENV PROJECT_DIR=/var/www/html \ APP_URL=localhost -RUN apk --no-cache add php-zlib php-mysqli php-gettext +RUN docker-php-ext-install mysqli gettext COPY ./src $PROJECT_DIR COPY docker-entrypoint.sh /entrypoint.sh VOLUME $PROJECT_DIR/storage -ENTRYPOINT ["/bin/sh", "/entrypoint.sh"] +ENTRYPOINT ["/bin/bash", "/entrypoint.sh"] CMD ["run"] diff --git a/README.md b/README.md index 34053f81..3ac9d5f3 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ You can also report problems on the [issues page](https://github.com/alextselegi and help the development progress. ### Docker -To start Easy!Appointments using Docker in development configuration with source files mounted into container, run: +To start Easy!Appointments using Docker in development configuration, with source files mounted into container, run: ``` docker-compose up ``` @@ -53,7 +53,14 @@ Production deployment can be made by changing required values in .env file (DB_P ``` docker-compose -f docker-compose.prod.yml up -d ``` -Database data will be stored in named volume "easy-appointments-data", and app storage (logs, cache, uploads) in "easy-appointments-data". + +Database data will be stored in named volume `easyappointments_easy-appointments-data`, and app storage (logs, cache, uploads) in `easyappointments_easy-appointments-storage`. +To find where exactly they are stored, you can run +``` +docker volume inspect easyappointments_easy-appointments-storage +``` + +Production containers will automatically be restarted in case of crash / server reboot. For more info, take a look into `docker-compose.prod.yml` file. ### User Feedback Whether it is new ideas or defects, your feedback is highly appreciated and will be taken into diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index bdf04318..712bedf4 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -23,7 +23,7 @@ services: env_file: - .env volumes: - - easy-appointments-storage:/app/src/storage + - easy-appointments-storage:/var/www/html/src/storage restart: always volumes: diff --git a/docker-compose.yml b/docker-compose.yml index f3d914df..cdc03837 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,13 +13,15 @@ services: build: context: . volumes: - - ./src:/app + - ./src:/var/www/html command: dev ports: - ${APP_HOST}:80:80 environment: - DB_HOST=database:3306 - APP_URL=localhost + depends_on: + - database env_file: - .env restart: always diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index f6981a31..cf82c818 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -6,7 +6,7 @@ createAppSettings() { 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 - if [ "$EMAIL_PROTOCOL" == "smtp" ]; then + if [ "$EMAIL_PROTOCOL" = "smtp" ]; then echo "Setting up email..." sed -i "s/\$config\['protocol'\] = 'mail'/\$config['protocol'] = 'smtp'/g" $PROJECT_DIR/application/config/email.php sed -i "s#// \$config\['smtp_host'\] = ''#\$config['smtp_host'] = '$SMTP_HOST'#g" $PROJECT_DIR/application/config/email.php @@ -16,31 +16,22 @@ createAppSettings() { sed -i "s#// \$config\['smtp_port'\] = 25#\$config['smtp_port'] = $SMTP_PORT#g" $PROJECT_DIR/application/config/email.php fi sed -i "s/url-to-easyappointments-directory/$APP_URL/g" $PROJECT_DIR/config.php -} -updateApacheSettings() { - 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 + chown -R www-data $PROJECT_DIR } -if [ "$1" == "run" ]; then +if [ "$1" = "run" ]; then echo "Preparing Easy!Appointments production configuration.." createAppSettings - updateApacheSettings + echo "Starting Easy!Appointments production server.." - echo "Starting Easy!Appointments development server.." + exec docker-php-entrypoint apache2-foreground - exec httpd -D FOREGROUND - -elif [ "$1" == "dev" ]; then +elif [ "$1" = "dev" ]; then echo "Preparing Easy!Appointments development configuration.." @@ -48,11 +39,9 @@ elif [ "$1" == "dev" ]; then createAppSettings sed -i "s/DEBUG_MODE = FALSE/DEBUG_MODE = TRUE/g" $PROJECT_DIR/config.php - updateApacheSettings - echo "Starting Easy!Appointments production server.." - exec httpd -D FOREGROUND + exec docker-php-entrypoint apache2-foreground fi exec $@