forked from mirrors/easyappointments
email settings as ENV variables inside Docker containers
This commit is contained in:
parent
4bebdf4bec
commit
547bad01f1
5 changed files with 49 additions and 36 deletions
15
.env
15
.env
|
@ -1,10 +1,19 @@
|
||||||
DB_USERNAME=easyappointments
|
DB_USERNAME=easyapp
|
||||||
DB_NAME=easyappointments
|
DB_NAME=easyapp
|
||||||
|
|
||||||
# before deploying to production change to harder password
|
# before deploying to production change to harder password
|
||||||
DB_PASSWORD=change-that-password
|
DB_PASSWORD=veryhardpassword
|
||||||
|
|
||||||
# change to you installation address
|
# change to you installation address
|
||||||
APP_URL=localhost
|
APP_URL=localhost
|
||||||
APP_HOST=0.0.0.0
|
APP_HOST=0.0.0.0
|
||||||
APP_PORT=80
|
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
|
||||||
|
|
||||||
|
|
|
@ -19,12 +19,9 @@ services:
|
||||||
ports:
|
ports:
|
||||||
- 80:80
|
- 80:80
|
||||||
environment:
|
environment:
|
||||||
- DB_NAME=${DB_NAME}
|
|
||||||
- DB_USERNAME=${DB_USERNAME}
|
|
||||||
- DB_PASSWORD=${DB_PASSWORD}
|
|
||||||
- DB_HOST=database:3306
|
- DB_HOST=database:3306
|
||||||
- APP_URL=${APP_URL}
|
env_file:
|
||||||
- APP_HOST=${APP_HOST}
|
- .env
|
||||||
volumes:
|
volumes:
|
||||||
- easy-appointments-storage:/app/src/storage
|
- easy-appointments-storage:/app/src/storage
|
||||||
restart: always
|
restart: always
|
||||||
|
|
|
@ -18,9 +18,8 @@ services:
|
||||||
ports:
|
ports:
|
||||||
- ${APP_HOST}:80:80
|
- ${APP_HOST}:80:80
|
||||||
environment:
|
environment:
|
||||||
- DB_NAME=easyapp
|
|
||||||
- DB_USERNAME=easyapp
|
|
||||||
- DB_PASSWORD=veryhardpassword
|
|
||||||
- DB_HOST=database:3306
|
- DB_HOST=database:3306
|
||||||
- APP_URL=localhost
|
- APP_URL=localhost
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
restart: always
|
restart: always
|
|
@ -1,23 +1,42 @@
|
||||||
#!/usr/bin/env sh
|
#!/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
|
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_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_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_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/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
|
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#^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<Directory \"$PROJECT_DIR\">\n\tAllowOverride All\n</Directory>\n" >> /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
|
chown -R apache:apache $PROJECT_DIR
|
||||||
chmod -R 777 $PROJECT_DIR/storage/uploads
|
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
|
exec httpd -D FOREGROUND
|
||||||
|
|
||||||
|
@ -25,24 +44,13 @@ elif [ "$1" == "dev" ]; then
|
||||||
|
|
||||||
echo "Preparing Easy!Appointments development configuration.."
|
echo "Preparing Easy!Appointments development configuration.."
|
||||||
|
|
||||||
if [ ! -e "$PROJECT_DIR/config.php" ]; then
|
|
||||||
cp $PROJECT_DIR/config-sample.php $PROJECT_DIR/config.php
|
createAppSettings
|
||||||
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/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
|
updateApacheSettings
|
||||||
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
|
echo "Starting Easy!Appointments production server.."
|
||||||
chmod -R 777 $PROJECT_DIR/storage/uploads
|
|
||||||
|
|
||||||
echo "Starting Easy!Appointments server.."
|
|
||||||
|
|
||||||
exec httpd -D FOREGROUND
|
exec httpd -D FOREGROUND
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue