Fix tracking issues with .env

This commit is contained in:
Corey 2025-04-07 03:26:51 -04:00
parent 2827a0363e
commit dcd8479c79
Signed by: coco
GPG Key ID: 051138DA6AEE3E60
6 changed files with 11 additions and 8 deletions

0
.env
View File

2
.gitignore vendored
View File

@ -1 +1 @@
.env config

View File

@ -34,8 +34,8 @@ That's it! All the setup is handled for you. Check out the [official LSB documen
## Notes ## Notes
- If using WSL with Windows, make sure [the project is stored in the WSL file system](https://learn.microsoft.com/en-us/windows/wsl/filesystems#file-storage-and-performance-across-file-systems) for best performance. - If using WSL with Windows, make sure [the project is stored in the WSL file system](https://learn.microsoft.com/en-us/windows/wsl/filesystems#file-storage-and-performance-across-file-systems) for best performance.
- To facilitate automatically generating secure database passwords and simplify the setup process, the `.env` file is intentionally empty and untracked by Git. - Secure database passwords and a default user and database name are generated into `config/.env` to simplify the setup process.
- **Optional** - You can manually populate this _before_ building the containers with these variables: - **Optional** - You can manually create this _before_ building the containers with these variables:
``` ```
MARIADB_DATABASE= MARIADB_DATABASE=
MARIADB_USER= MARIADB_USER=

View File

@ -1,13 +1,13 @@
x-common: &common # Configs used by more than one service. x-common: &common # Configs used by more than one service.
image: lsd_service image: lsd_service
pull_policy: never pull_policy: never
env_file: .env # Automatically generated by MariaDB service entrypoint.
entrypoint: ["/entrypoint.sh"] # Copies the MariaDB env vars into corresponding LSB settings. entrypoint: ["/entrypoint.sh"] # Copies the MariaDB env vars into corresponding LSB settings.
environment: environment:
XI_NETWORK_HTTP_HOST: 0.0.0.0 XI_NETWORK_HTTP_HOST: 0.0.0.0
XI_NETWORK_ZMQ_IP: world XI_NETWORK_ZMQ_IP: world
XI_NETWORK_SQL_HOST: database XI_NETWORK_SQL_HOST: database
volumes: # YAML merge can't be used with sequences, so bind everything here. (SEE NOTE ABOUT WSL IN README!) volumes: # YAML merge can't be used with sequences, so bind everything here. (SEE NOTE ABOUT WSL IN README!)
- ./config:/config
- ./.git:/.git # Since LSB is a submodule, we want to preserve - ./.git:/.git # Since LSB is a submodule, we want to preserve
- ./server/.git:/server/.git # the directory structure inside the container. - ./server/.git:/server/.git # the directory structure inside the container.
- ./server/log:/server/log - ./server/log:/server/log
@ -26,7 +26,7 @@ services:
entrypoint: ["/mariadb-entrypoint.sh"] entrypoint: ["/mariadb-entrypoint.sh"]
restart: always restart: always
volumes: volumes:
- ./.env:/env/.env - ./config:/config
- ./mariadb-entrypoint.sh:/mariadb-entrypoint.sh # Custom entrypoint to generate .env. - ./mariadb-entrypoint.sh:/mariadb-entrypoint.sh # Custom entrypoint to generate .env.
- ./server/sql:/docker-entrypoint-initdb.d # Initializes the database. - ./server/sql:/docker-entrypoint-initdb.d # Initializes the database.
- database:/var/lib/mysql - database:/var/lib/mysql

View File

@ -1,6 +1,9 @@
#!/bin/bash #!/bin/bash
# Export XI_ variables from corresponding MARIADB_ variables. # Export XI_ variables from corresponding MARIADB_ variables.
set -a
source "/config/.env"
set +a
export XI_NETWORK_SQL_DATABASE=$MARIADB_DATABASE export XI_NETWORK_SQL_DATABASE=$MARIADB_DATABASE
export XI_NETWORK_SQL_LOGIN=$MARIADB_USER export XI_NETWORK_SQL_LOGIN=$MARIADB_USER
export XI_NETWORK_SQL_PASSWORD="$MARIADB_PASSWORD" export XI_NETWORK_SQL_PASSWORD="$MARIADB_PASSWORD"

View File

@ -1,9 +1,9 @@
#!/bin/bash #!/bin/bash
ENV_FILE="/env/.env" ENV_FILE="/config/.env"
# Set default values if the .env file is empty. # Set default values if the .env file doesn't exist.
if [ ! -s "$ENV_FILE" ]; then if [ ! -e "$ENV_FILE" ]; then
MARIADB_DATABASE=xidb MARIADB_DATABASE=xidb
MARIADB_USER=xiadmin MARIADB_USER=xiadmin
XI_NETWORK_ENABLE_HTTP=1 XI_NETWORK_ENABLE_HTTP=1