mirror of
https://github.com/suitenumerique/messages.git
synced 2026-08-17 21:25:41 +02:00
* (ops) implement production docker images
Github workflows:
- moved docker-publish jobs into a separate file on push main only
Backend:
- added healthcheck on backend Dockerfile + minor fixes
- bumped django to 5.1.15 to mitigate major CVE
- moved /healthz endpoint to /__heartbeat__ + added db connection
check
Frontend:
- Added runtime-prod Dockerfile target + minor fixes on the Dockerfile
- bump next to 15.5.9 to mitigate major CVE
- moved nginx config to standard nginx container configuration
template, fixed `scalingo_postfrontend` accordingly
Keycloak:
- Added production Dockerfile
- Removed scalingo_pgdump script & cron.json
socks-proxy:
- added package upgrades run into runtime Dockerfile stage
Misc:
- removed scalingo_pgdump.sh & cron.json
- fixed compose and e2e nginx configs with /healthz replacement
* (fix) coderabbit recommandations
387 lines
9.1 KiB
YAML
387 lines
9.1 KiB
YAML
name: st-messages
|
|
|
|
services:
|
|
postgresql:
|
|
image: postgres:16.6
|
|
ports:
|
|
- "8912:5432"
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"]
|
|
interval: 1s
|
|
timeout: 2s
|
|
retries: 300
|
|
env_file:
|
|
- env.d/development/postgresql.defaults
|
|
- env.d/development/postgresql.local
|
|
|
|
redis:
|
|
image: redis:5
|
|
ports:
|
|
- "8913:6379"
|
|
|
|
opensearch:
|
|
image: opensearchproject/opensearch:2.19.2
|
|
environment:
|
|
- discovery.type=single-node
|
|
- bootstrap.memory_lock=true
|
|
- "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m"
|
|
- "DISABLE_INSTALL_DEMO_CONFIG=true"
|
|
- "DISABLE_SECURITY_PLUGIN=true"
|
|
# - http.cors.enabled=true
|
|
# - "http.cors.allow-origin=/.*/"
|
|
ports:
|
|
- "8914:9200" # REST API
|
|
- "8915:9600" # Performance Analyzer
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:9200"]
|
|
interval: 1s
|
|
timeout: 5s
|
|
retries: 60
|
|
ulimits:
|
|
memlock:
|
|
soft: -1 # Set memlock to unlimited (no soft or hard limit)
|
|
hard: -1
|
|
nofile:
|
|
soft: 65536 # Maximum number of open files for the opensearch user - set to at least 65536
|
|
hard: 65536
|
|
|
|
mailcatcher:
|
|
image: maildev/maildev:2.2.1
|
|
ports:
|
|
- "8904:1080"
|
|
- "8917:1025"
|
|
|
|
objectstorage:
|
|
# user: ${DOCKER_USER:-1000}
|
|
image: minio/minio
|
|
environment:
|
|
- MINIO_ROOT_USER=st-messages
|
|
- MINIO_ROOT_PASSWORD=password
|
|
ports:
|
|
- "8906:9000"
|
|
- "8907:9001"
|
|
healthcheck:
|
|
test: ["CMD", "mc", "ready", "local"]
|
|
interval: 1s
|
|
timeout: 20s
|
|
retries: 300
|
|
entrypoint: ""
|
|
command: minio server --console-address :9001 /data
|
|
volumes:
|
|
- ./data/media:/data
|
|
|
|
objectstorage-createbucket:
|
|
image: minio/mc
|
|
depends_on:
|
|
objectstorage:
|
|
condition: service_healthy
|
|
environment:
|
|
- MC_HOST=http://objectstorage:9000
|
|
entrypoint: >
|
|
sh -c "
|
|
/usr/bin/mc alias set st-messages $${MC_HOST} st-messages password && \
|
|
/usr/bin/mc mb st-messages/msg-imports --ignore-existing && \
|
|
/usr/bin/mc ilm rule rm --all --force st-messages/msg-imports || true && \
|
|
/usr/bin/mc ilm rule add --expire-days 1 st-messages/msg-imports"
|
|
|
|
backend-base:
|
|
build:
|
|
context: src/backend
|
|
target: runtime-dev
|
|
args:
|
|
DOCKER_USER: ${DOCKER_USER:-1000}
|
|
user: ${DOCKER_USER:-1000}
|
|
volumes:
|
|
- ./src/backend:/app
|
|
- ./data/static:/data/static
|
|
healthcheck:
|
|
test: ["CMD", "python", "-c", "import urllib.request as u; u.urlopen('http://localhost:8000/__heartbeat__/', timeout=1)"]
|
|
interval: 3s
|
|
retries: 3
|
|
start_period: 10s
|
|
|
|
backend-dev:
|
|
extends: backend-base
|
|
environment:
|
|
- PYLINTHOME=/app/.pylint.d
|
|
- DJANGO_CONFIGURATION=Development
|
|
env_file:
|
|
- env.d/development/backend.defaults
|
|
- env.d/development/backend.local
|
|
ports:
|
|
- "8901:8000"
|
|
depends_on:
|
|
postgresql:
|
|
condition: service_healthy
|
|
# restart: true
|
|
objectstorage:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_started
|
|
opensearch:
|
|
condition: service_healthy
|
|
keycloak:
|
|
condition: service_started
|
|
mailcatcher:
|
|
condition: service_started
|
|
|
|
backend-db:
|
|
extends: backend-base
|
|
profiles:
|
|
- tools
|
|
environment:
|
|
- DJANGO_CONFIGURATION=DevelopmentMinimal
|
|
env_file:
|
|
- env.d/development/backend.defaults
|
|
- env.d/development/backend.local
|
|
ports:
|
|
- "8901:8000"
|
|
|
|
backend-poetry:
|
|
profiles:
|
|
- tools
|
|
volumes:
|
|
- ./src/backend:/app
|
|
build:
|
|
context: src/backend/
|
|
target: poetry
|
|
pull_policy: build
|
|
|
|
celery-dev:
|
|
build:
|
|
context: src/backend
|
|
target: runtime-dev
|
|
args:
|
|
DOCKER_USER: ${DOCKER_USER:-1000}
|
|
user: ${DOCKER_USER:-1000}
|
|
command: ["celery", "-A", "messages.celery_app", "worker", "-l", "DEBUG", "-Q", "celery,default"]
|
|
environment:
|
|
- DJANGO_CONFIGURATION=Development
|
|
env_file:
|
|
- env.d/development/backend.defaults
|
|
- env.d/development/backend.local
|
|
volumes:
|
|
- ./src/backend:/app
|
|
- ./data/static:/data/static
|
|
depends_on:
|
|
- backend-dev
|
|
|
|
celery-ui:
|
|
build:
|
|
context: src/backend
|
|
target: runtime-dev
|
|
args:
|
|
DOCKER_USER: ${DOCKER_USER:-1000}
|
|
user: ${DOCKER_USER:-1000}
|
|
depends_on:
|
|
- redis
|
|
environment:
|
|
- FLOWER_UNAUTHENTICATED_API=true
|
|
- DJANGO_CONFIGURATION=Development
|
|
env_file:
|
|
- env.d/development/backend.defaults
|
|
- env.d/development/backend.local
|
|
volumes:
|
|
- ./src/backend:/app
|
|
ports:
|
|
- "8903:8803"
|
|
command: celery -A messages.celery_app flower --port=8803
|
|
|
|
frontend-base:
|
|
user: "${DOCKER_USER:-1000}"
|
|
build:
|
|
context: ./src/frontend
|
|
dockerfile: Dockerfile
|
|
target: frontend-deps
|
|
args:
|
|
DOCKER_USER: ${DOCKER_USER:-1000}
|
|
|
|
frontend-dev:
|
|
extends: frontend-base
|
|
env_file:
|
|
- env.d/development/frontend.defaults
|
|
- env.d/development/frontend.local
|
|
command: ["npm", "run", "dev"]
|
|
volumes:
|
|
- ./src/frontend/:/home/frontend/
|
|
ports:
|
|
- "8900:3000"
|
|
|
|
frontend-tools:
|
|
extends: frontend-base
|
|
profiles:
|
|
- frontend-tools
|
|
volumes:
|
|
- ./src/backend/core/api/openapi.json:/home/backend/core/api/openapi.json
|
|
- ./src/frontend/:/home/frontend/
|
|
|
|
frontend-tools-amd64:
|
|
extends: frontend-tools
|
|
platform: linux/amd64
|
|
|
|
crowdin:
|
|
image: crowdin/cli:4.11.0
|
|
volumes:
|
|
- ".:/app"
|
|
env_file:
|
|
- env.d/development/crowdin.defaults
|
|
- env.d/development/crowdin.local
|
|
user: "${DOCKER_USER:-1000}"
|
|
working_dir: /app
|
|
|
|
mta-in:
|
|
build:
|
|
context: src/mta-in
|
|
target: runtime-prod
|
|
env_file:
|
|
- env.d/development/mta-in.defaults
|
|
- env.d/development/mta-in.local
|
|
ports:
|
|
- "8910:25"
|
|
depends_on:
|
|
- backend-dev
|
|
|
|
mta-in-test:
|
|
profiles:
|
|
- tools
|
|
build:
|
|
context: src/mta-in
|
|
target: runtime-dev
|
|
env_file:
|
|
- env.d/development/mta-in.defaults
|
|
- env.d/development/mta-in.local
|
|
environment:
|
|
- EXEC_CMD=true
|
|
- MDA_API_BASE_URL=http://localhost:8000/api/mail/
|
|
- MTA_HOST=localhost
|
|
command: pytest -vvs tests/
|
|
volumes:
|
|
- ./src/mta-in:/app
|
|
|
|
mta-in-poetry:
|
|
profiles:
|
|
- tools
|
|
volumes:
|
|
- ./src/mta-in:/app
|
|
build:
|
|
context: src/mta-in
|
|
target: poetry
|
|
pull_policy: build
|
|
|
|
mta-out:
|
|
build:
|
|
context: src/mta-out
|
|
target: runtime-prod
|
|
env_file:
|
|
- env.d/development/mta-out.defaults
|
|
- env.d/development/mta-out.local
|
|
ports:
|
|
- "8911:587"
|
|
depends_on:
|
|
mailcatcher:
|
|
condition: service_started
|
|
|
|
mta-out-test:
|
|
profiles:
|
|
- tools
|
|
build:
|
|
context: src/mta-out
|
|
target: runtime-dev
|
|
env_file:
|
|
- env.d/development/mta-out.defaults
|
|
- env.d/development/mta-out.local
|
|
environment:
|
|
- EXEC_CMD=true
|
|
- MTA_OUT_SMTP_HOST=localhost:587
|
|
- MTA_OUT_SMTP_USERNAME=user
|
|
- MTA_OUT_SMTP_PASSWORD=pass
|
|
- SMTP_RELAY_HOST=localhost:2525
|
|
command: pytest -vvs tests/
|
|
volumes:
|
|
- ./src/mta-out:/app
|
|
|
|
socks-proxy:
|
|
build:
|
|
context: src/socks-proxy
|
|
target: runtime
|
|
env_file:
|
|
- env.d/development/socks-proxy.defaults
|
|
- env.d/development/socks-proxy.local
|
|
ports:
|
|
- "8916:1080"
|
|
|
|
socks-proxy-test:
|
|
profiles:
|
|
- tools
|
|
build:
|
|
context: src/socks-proxy/tests
|
|
environment:
|
|
- SOCKS_PROXY1=user1:pwd1@socks-proxy:1080
|
|
- SOCKS_PROXY2=user2:pwd2@socks-proxy:1080
|
|
depends_on:
|
|
socks-proxy:
|
|
condition: service_started
|
|
|
|
mta-out-poetry:
|
|
profiles:
|
|
- tools
|
|
volumes:
|
|
- ./src/mta-out:/app
|
|
build:
|
|
context: src/mta-out
|
|
target: poetry
|
|
pull_policy: build
|
|
|
|
keycloak:
|
|
image: quay.io/keycloak/keycloak:26.2.5
|
|
volumes:
|
|
- ./src/keycloak/realm.json:/opt/keycloak/data/import/realm.json:ro
|
|
- ./src/keycloak/themes/dsfr-2.2.1.jar:/opt/keycloak/providers/keycloak-theme.jar:ro
|
|
environment:
|
|
- HOST=http://localhost:8902
|
|
- ADMIN_HOST=http://localhost:8902
|
|
command:
|
|
- start-dev
|
|
- --features=preview
|
|
- --import-realm
|
|
- --proxy=edge
|
|
- --hostname=$${HOST}
|
|
- --hostname-admin=$${ADMIN_HOST}
|
|
- --http-port=8802
|
|
env_file:
|
|
- env.d/development/keycloak.defaults
|
|
- env.d/development/keycloak.local
|
|
ports:
|
|
- "8902:8802"
|
|
depends_on:
|
|
- postgresql
|
|
|
|
mpa:
|
|
build:
|
|
context: src/mpa/rspamd
|
|
environment:
|
|
- RSPAMD_password=password
|
|
- PORT=8010
|
|
ports:
|
|
- "8918:8010"
|
|
depends_on:
|
|
redis:
|
|
condition: service_started
|
|
|
|
mpa-test:
|
|
profiles:
|
|
- tools
|
|
build:
|
|
context: src/mpa/tests
|
|
environment:
|
|
- RSPAMD_URL=http://mpa:8010/_api
|
|
- RSPAMD_AUTH=Bearer password
|
|
command: pytest -vvs tests/
|
|
volumes:
|
|
- ./src/mpa/tests:/app/tests
|
|
depends_on:
|
|
mpa:
|
|
condition: service_started
|
|
redis:
|
|
condition: service_started
|