Skip to content

Commit

Permalink
Update for secret.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrishsieh committed Feb 12, 2019
1 parent ab515cc commit 3949dce
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 19 deletions.
8 changes: 3 additions & 5 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
CRM_VER=latest
#CRM_VER=3.2.4

## Database setting.
MYSQL_ROOT_PWD=mysqlRoot
MYSQL_USER_DB=churchcrm
MYSQL_USER=churchcrm
MYSQL_USER_PWD=mysqlPWD
SECRET_FILE=./secret.dat

VHOST_NAME=localhost

## mysql mariadb version
#MYSQL_VER=latest
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/www
/log
/cert
/ca
7 changes: 5 additions & 2 deletions crm_init.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@

source /run/secrets/secret_file

set -x

download_crm() {
Expand Down Expand Up @@ -31,9 +34,9 @@ if ! [ -f /var/www/default/churchcrm/Include/Config.php ]; then
# Create ChurchCRM Config File
sed -i "s/||DB_SERVER_NAME||/mysql/g" /var/www/default/churchcrm/Include/Config.php
sed -i "s/||DB_SERVER_PORT||/3306/g" /var/www/default/churchcrm/Include/Config.php
sed -i "s/||DB_NAME||/$MYSQL_USER_DB/g" /var/www/default/churchcrm/Include/Config.php
sed -i "s/||DB_NAME||/$MYSQL_DATABASE/g" /var/www/default/churchcrm/Include/Config.php
sed -i "s/||DB_USER||/$MYSQL_USER/g" /var/www/default/churchcrm/Include/Config.php
sed -i "s/||DB_PASSWORD||/$MYSQL_USER_PWD/g" /var/www/default/churchcrm/Include/Config.php
sed -i "s/||DB_PASSWORD||/$MYSQL_PASSWORD/g" /var/www/default/churchcrm/Include/Config.php
sed -i "s/||URL||//g" /var/www/default/churchcrm/Include/Config.php
sed -i "s/||ROOT_PATH||//g" /var/www/default/churchcrm/Include/Config.php
fi
Expand Down
23 changes: 11 additions & 12 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ services:
container_name: mysql
image: mariadb:${MYSQL_VER:-10.3}
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PWD:-mysqlRoot}
MYSQL_DATABASE: ${MYSQL_USER_DB:-churchcrm}
MYSQL_USER: ${MYSQL_USER:-churchcrm}
MYSQL_PASSWORD: ${MYSQL_USER_PWD:-mysqlPWD}
MYSQL_ROOT_PASSWORD_FILE: /run/secrets/secret_file
volumes:
## keep database
- mysql_data:/var/lib/mysql
secrets:
- secret_file

php:
container_name: php
Expand All @@ -26,9 +25,6 @@ services:
environment:
## version can be latest or 3.2.3 ...
CRM_RELEASE_VERSION: ${CRM_VER:-latest}
MYSQL_USER: ${MYSQL_USER:-churchcrm}
MYSQL_USER_PWD: ${MYSQL_USER_PWD:-mysqlPWD}
MYSQL_USER_DB: ${MYSQL_USER_DB:-churchcrm}
FORWARD_PORTS_TO_LOCALHOST: '3306:mysql:3306, 80:apache:80, 443:apache:443'
DOCKER_LOGS: 0
# DEBUG_RUNTIME: 1
Expand All @@ -41,6 +37,8 @@ services:
- ./log/php:/var/log/php
## used when enable email catch-all
- mail:/var/mail
secrets:
- secret_file

apache:
container_name: apache
Expand All @@ -55,23 +53,24 @@ services:
MAIN_VHOST_ENABLE: 1
MAIN_VHOST_SSL_GEN: 1
MAIN_VHOST_SSL_TYPE: both
MAIN_VHOST_SSL_CN: localhost
MAIN_VHOST_SSL_CN: ${VHOST_NAME:-localhost}
MAIN_VHOST_DOCROOT: churchcrm
# DOCKER_LOGS: 1
# DEBUG_RUNTIME: 1
# DEBUG_ENTRYPOINT: 2
volumes:
- ./www:/var/www/default
## for keep certs
- ./cert:/etc/httpd/cert/main
- ca:/ca
- ./ca:/ca
- httpd:/shared/httpd
ports:
- "80:80"
- "443:443"

volumes:
mysql_data: null
ca: null
mail: null
httpd: null

secrets:
secret_file:
file: ${SECRET_FILE:-./secret.dat}
5 changes: 5 additions & 0 deletions secret.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Database setting.
MYSQL_ROOT_PASSWORD=mysqlRoot
MYSQL_DATABASE=churchcrm
MYSQL_USER=churchcrm
MYSQL_PASSWORD=mysqlPWD

0 comments on commit 3949dce

Please sign in to comment.