Containers now embed environment variables dynamically

This commit is contained in:
Smultar 2024-01-06 20:11:29 -06:00
parent 680e6ecd02
commit 2c8d2a0a8d
3 changed files with 32 additions and 7 deletions

16
.devcontainer/.env Normal file
View File

@ -0,0 +1,16 @@
# wf.database
MONGODB_URL='localhost'
MONGODB_PORT='27017'
MONDODB_DATABASE='openwf'
MONDODB_USERNAME='root'
MONDODB_PASSWORD='database'
# wf.server logs
LOG_LEVEL=trace
LOG_FILES=true
# Log Types
# fatal, error, warn, info, http, debug, trace
# Edit the following to your needs
# Remember to rebuild the container after editing this file

View File

@ -38,12 +38,11 @@
// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [3000, 27017],
"runArgs": ["--name", "wf.emulator"]
"runArgs": ["--name", "wf.emulator"],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "yarn install",
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
"remoteUser": "root"
}

View File

@ -18,6 +18,15 @@ services:
# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
network_mode: service:wf.database
environment:
MONGODB_USERNAME: ${MONDODB_USERNAME}
MONGODB_PASSWORD: ${MONDODB_PASSWORD}
MONGODB_DATABASE: ${MONDODB_DATABASE}
MONGODB_PORT: ${MONGODB_PORT}
MONGODB_URL: ${MONGODB_URL}
LOG_LEVEL: ${LOG_LEVEL}
LOG_FILES: ${LOG_FILES}
# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)
@ -29,10 +38,11 @@ services:
- mongodb-data:/data/db
# Uncomment to change startup options
# environment:
# MONGO_INITDB_ROOT_USERNAME: root
# MONGO_INITDB_ROOT_PASSWORD: example
# MONGO_INITDB_DATABASE: your-database-here
environment:
MONGO_INITDB_ROOT_USERNAME: ${MONGODB_USERNAME}
MONGO_INITDB_ROOT_PASSWORD: ${MONGODB_PASSWORD}
MONGO_INITDB_DATABASE: ${MONGODB_DATABASE}
MONGO_INITDB_PORT: ${MONGODB_PORT}
# Add "forwardPorts": ["27017"] to **devcontainer.json** to forward MongoDB locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)