From 1139400adde8faa44a7acba83ae6f8961b439802 Mon Sep 17 00:00:00 2001 From: Ian Stride Date: Wed, 27 Mar 2024 14:45:43 +0000 Subject: [PATCH] Introduce Docker Compose env file The current setup instructions require environment variables to be change in the the Docker Compose file, but this is very error-prone. An env file is recommended for managing environment variables. An example file ('env.example') is provided, with default values, which should be copied as '.env' in the same directory as the Docker Compose file, and modified locally. The setup instructions have been updated accordingly. First-time users are asked to focus on the contents of the .env file and not interfere with the main Docker Compose file. Additional instructions can be provided in the env file to give more help about each env var. --- README.md | 16 ++++++---------- docker_compose/docker-compose.yml | 10 +++++----- docker_compose/env.example | 11 +++++++++++ 3 files changed, 22 insertions(+), 15 deletions(-) create mode 100644 docker_compose/env.example diff --git a/README.md b/README.md index 018e5f72..f0a8e202 100644 --- a/README.md +++ b/README.md @@ -169,16 +169,12 @@ echo 'vm.max_map_count=262144' | sudo tee -a /etc/sysctl.d/60-vm-max_map_count.c cd /opt/formshare_docker_compose_20240213 sudo docker-compose pull -# Edit the docker-compose.yml file to set the MySQL root and FormShare admin passwords -sudo nano /opt/formshare_docker_compose_20240213/docker-compose.yml -# Press Alt+Shit+3 to show the line numbers in Nano - -Edit line 10: Change the root password from "my_secure_password" to your password -Edit line 67: Change the root password from "my_secure_password" to the same password of line 10 -Edit line 68: Change the admin user name (optional) -Edit line 69: Change the admin email address -Edit line 70: Change the admin user password from "my_secure_password" to your password -Edit line 75: Change the IP address for the IP address of the machine running the Docker service +# Set environment variables. Make sure to change the following: +# MYSQL_PASSWORD +# FORMSHARE_ADMIN_EMAIL +# FORMSHARE_ADMIN_PASSWORD +sudo wget -O .env https://raw.githubusercontent.com/qlands/FormShare/stable-2.33.0/docker_compose/env.example +sudo nano .env # Save the file with Ctlr+o Enter . Exit with Ctrl+x diff --git a/docker_compose/docker-compose.yml b/docker_compose/docker-compose.yml index f7d5234a..b381e0d6 100644 --- a/docker_compose/docker-compose.yml +++ b/docker_compose/docker-compose.yml @@ -7,7 +7,7 @@ services: cap_add: - SYS_NICE environment: - MYSQL_ROOT_PASSWORD: my_secure_password + MYSQL_ROOT_PASSWORD: ${MYSQL_PASSWORD} volumes: - /opt/formshare/mysql:/var/lib/mysql - /opt/formshare/mysql-files:/var/lib/mysql-files @@ -65,10 +65,10 @@ services: environment: MYSQL_HOST_NAME: 172.28.1.5 MYSQL_USER_NAME: root - MYSQL_USER_PASSWORD: my_secure_password - FORMSHARE_ADMIN_USER: admin - FORMSHARE_ADMIN_EMAIL: admin@myserver.com - FORMSHARE_ADMIN_PASSWORD: my_secure_password + MYSQL_USER_PASSWORD: ${MYSQL_PASSWORD} + FORMSHARE_ADMIN_USER: ${FORMSHARE_ADMIN_USER} + FORMSHARE_ADMIN_EMAIL: ${FORMSHARE_ADMIN_EMAIL} + FORMSHARE_ADMIN_PASSWORD: ${FORMSHARE_ADMIN_PASSWORD} ELASTIC_SEARCH_HOST: 172.28.1.2 ELASTIC_SEARCH_PORT: 9200 FORMSHARE_HOST: 172.28.1.4 diff --git a/docker_compose/env.example b/docker_compose/env.example new file mode 100644 index 00000000..2fee9b17 --- /dev/null +++ b/docker_compose/env.example @@ -0,0 +1,11 @@ +# Root password for MySQL. Must be changed. +MYSQL_PASSWORD=my_secure_password + +# Email address of FormShare admin user. Must be changed. +FORMSHARE_ADMIN_EMAIL=admin@myserver.com + +# Password of FormShare admin user. Must be changed. +FORMSHARE_ADMIN_PASSWORD=my_secure_password + +# Username of FormShare admin user. Optional to change. +FORMSHARE_ADMIN_USER=admin