mirror of
https://github.com/TheBinaryNinja/tvapp2.git
synced 2026-06-11 23:05:41 -04:00
initial push from external dev branches
This commit is contained in:
84
docker-compose.yml
Normal file
84
docker-compose.yml
Normal file
@@ -0,0 +1,84 @@
|
||||
# Pinned image versions — bump in lockstep with docker/*.Dockerfile.
|
||||
# MONGO = 7.0.15
|
||||
# Requires Docker Engine >= 24.0 and Docker Compose >= 2.20 (Compose Spec).
|
||||
# The legacy top-level `version:` key is intentionally omitted (deprecated in Compose v2).
|
||||
|
||||
services:
|
||||
# One-shot init: writes ${TVAPP2_CONFIG_DIR}/config.json from the MONGO_ROOT_USER /
|
||||
# MONGO_ROOT_PASS values in .env. The JSON template is embedded below — NO host file is
|
||||
# bind-mounted — so a deployment host needs only this compose file + .env, nothing else to
|
||||
# ship. (Bind-mounting a host template is a footgun: if the file is missing Docker silently
|
||||
# creates it as an empty *directory*, and config.json ends up empty.) Left untouched if an
|
||||
# existing config.json already targets the compose "mongo" host; regenerated otherwise
|
||||
# (e.g. a stale @127.0.0.1: config left by an all-in-one run).
|
||||
config-init:
|
||||
image: alpine:3.20
|
||||
environment:
|
||||
MONGO_ROOT_USER: ${MONGO_ROOT_USER}
|
||||
MONGO_ROOT_PASS: ${MONGO_ROOT_PASS}
|
||||
volumes:
|
||||
- ${TVAPP2_CONFIG_DIR}:/out
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- |
|
||||
set -eu
|
||||
if [ -s /out/config.json ] && grep -q '@mongo:' /out/config.json; then
|
||||
echo "[config-init] /out/config.json already targets @mongo: — leaving alone"
|
||||
exit 0
|
||||
fi
|
||||
if [ -s /out/config.json ]; then
|
||||
echo "[config-init] /out/config.json does not target @mongo: — regenerating"
|
||||
fi
|
||||
printf '{\n "mongoUri": "mongodb://%s:%s@mongo:27017/tvapp2?authSource=admin",\n "port": 3000,\n "logLevel": "info"\n}\n' \
|
||||
"$$MONGO_ROOT_USER" "$$MONGO_ROOT_PASS" > /out/config.json
|
||||
echo "[config-init] wrote /out/config.json"
|
||||
restart: "no"
|
||||
|
||||
app:
|
||||
image: iflip721/tvapp2-app-stack:2.0.5-dev
|
||||
build:
|
||||
context: .
|
||||
dockerfile: docker/app.Dockerfile
|
||||
ports:
|
||||
- "3000:3000"
|
||||
volumes:
|
||||
# config.json is generated by the config-init service from .env (embedded template).
|
||||
# Set TVAPP2_CONFIG_DIR in .env to the host directory that holds it.
|
||||
- ${TVAPP2_CONFIG_DIR}:/etc/tvapp2:rw
|
||||
depends_on:
|
||||
config-init:
|
||||
condition: service_completed_successfully
|
||||
mongo:
|
||||
condition: service_healthy
|
||||
networks: [tvnet]
|
||||
restart: unless-stopped
|
||||
|
||||
mongo:
|
||||
image: mongo:7.0.15
|
||||
environment:
|
||||
MONGO_INITDB_ROOT_USERNAME: ${MONGO_ROOT_USER}
|
||||
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_ROOT_PASS}
|
||||
ports:
|
||||
# Expose mongod on the host. Override the host-side port with
|
||||
# MONGO_HOST_PORT in .env (defaults to 27017).
|
||||
- "${MONGO_HOST_PORT:-27017}:27017"
|
||||
volumes:
|
||||
# Persistent MongoDB data. Set MONGO_DATA_PATH in .env to an absolute
|
||||
# host path (e.g. /srv/tvapp2/mongo) for a bind mount; leave unset to
|
||||
# use the named volume defined below.
|
||||
- ${MONGO_DATA_PATH:-mongo-data}:/data/db
|
||||
healthcheck:
|
||||
test: ["CMD", "mongosh", "--quiet", "--eval", "db.adminCommand('ping').ok"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
networks: [tvnet]
|
||||
restart: unless-stopped
|
||||
|
||||
volumes:
|
||||
# Fallback named volume — used only when MONGO_DATA_PATH is unset.
|
||||
mongo-data:
|
||||
|
||||
networks:
|
||||
tvnet:
|
||||
Reference in New Issue
Block a user