diff --git a/.env b/.env index 6022dd2f..e22bd892 100644 --- a/.env +++ b/.env @@ -1,10 +1,19 @@ -DB_USERNAME=easyappointments -DB_NAME=easyappointments +DB_USERNAME=easyapp +DB_NAME=easyapp # before deploying to production change to harder password -DB_PASSWORD=change-that-password +DB_PASSWORD=veryhardpassword # change to you installation address APP_URL=localhost APP_HOST=0.0.0.0 -APP_PORT=80 \ No newline at end of file +APP_PORT=80 + +# email settings - set to 'smtp' and provide SMTP settings if you want to send emails +EMAIL_PROTOCOL=mail +SMTP_HOST=smtp.gmail.com +SMTP_USER=user +SMTP_PASS=password +SMTP_CRYPTO=ssl +SMTP_PORT=25 + diff --git a/Dockerfile b/Dockerfile index 786aa408..a9d9b1d2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,4 +11,4 @@ COPY docker-entrypoint.sh /entrypoint.sh VOLUME $PROJECT_DIR/storage ENTRYPOINT ["/bin/sh", "/entrypoint.sh"] -CMD ["run"] \ No newline at end of file +CMD ["run"] diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 6dfe9387..bdf04318 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -19,16 +19,13 @@ services: 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} + env_file: + - .env volumes: - easy-appointments-storage:/app/src/storage restart: always volumes: easy-appointments-data: - easy-appointments-storage: \ No newline at end of file + easy-appointments-storage: diff --git a/docker-compose.yml b/docker-compose.yml index 4f7f8dd7..f3d914df 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,9 +18,8 @@ services: 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 + env_file: + - .env + restart: always diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index f2c0d9da..f6981a31 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -1,23 +1,42 @@ #!/usr/bin/env sh -if [ "$1" == "run" ]; then - - echo "Preparing Easy!Appointments production configuration.." +createAppSettings() { 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 + 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 + sed -i "s#// \$config\['smtp_user'\] = ''#\$config['smtp_user'] = '$SMTP_USER'#g" $PROJECT_DIR/application/config/email.php + sed -i "s#// \$config\['smtp_pass'\] = ''#\$config['smtp_pass'] = '$SMTP_PASS'#g" $PROJECT_DIR/application/config/email.php + sed -i "s#// \$config\['smtp_crypto'\] = 'ssl'#\$config['smtp_crypto'] = '$SMTP_CRYPTO'#g" $PROJECT_DIR/application/config/email.php + 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 + 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.." + +if [ "$1" == "run" ]; then + + echo "Preparing Easy!Appointments production configuration.." + + createAppSettings + + updateApacheSettings + + echo "Starting Easy!Appointments development server.." exec httpd -D FOREGROUND @@ -25,26 +44,15 @@ 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 + createAppSettings + sed -i "s/DEBUG_MODE = FALSE/DEBUG_MODE = TRUE/g" $PROJECT_DIR/config.php - chown -R apache:apache $PROJECT_DIR - chmod -R 777 $PROJECT_DIR/storage/uploads + updateApacheSettings - echo "Starting Easy!Appointments server.." + echo "Starting Easy!Appointments production server.." exec httpd -D FOREGROUND fi -exec $@ \ No newline at end of file +exec $@