Last active
March 3, 2024 20:35
-
-
Save kanzitelli/8a23774ba3d03850f81645c343deafb4 to your computer and use it in GitHub Desktop.
Deploying PostgreSQL and Redis behind Traefik in the Cloud
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3.7" | |
services: | |
proxy: | |
image: traefik:latest | |
command: | |
- "--api.insecure=true" | |
- "--providers.docker=true" | |
- "--providers.docker.exposedbydefault=false" | |
# Endpoints setup | |
- "--entrypoints.postgres.address=:5432" # PostgreSQL endpoint | |
- "--entrypoints.redis.address=:6379" # Redis endpoint | |
ports: | |
- "6969:8080" # Traefik dashboard | |
- "5432:5432" # PostgreSQL port | |
- "6379:6379" # Redis port | |
volumes: | |
- /var/run/docker.sock:/var/run/docker.sock | |
postgres: | |
image: postgres | |
restart: always | |
environment: | |
- POSTGRES_DB=${DB_NAME} | |
- POSTGRES_USER=${DB_USER} | |
- POSTGRES_PASSWORD=${DB_PASS} | |
volumes: | |
- ./appdata/postgres:/var/lib/postgresql/data | |
labels: | |
- "traefik.enable=true" | |
# routers | |
- "traefik.tcp.routers.postgres.rule=HostSNI(`*`)" | |
- "traefik.tcp.routers.postgres.entryPoints=postgres" | |
- "traefik.tcp.routers.postgres.service=postgres" | |
# services (needed for TCP) | |
- "traefik.tcp.services.postgres.loadbalancer.server.port=5432" | |
redis: | |
image: bitnami/redis:latest | |
restart: always | |
environment: | |
# ALLOW_EMPTY_PASSWORD is recommended only for development. | |
- ALLOW_EMPTY_PASSWORD=yes | |
- REDIS_DISABLE_COMMANDS=FLUSHDB,FLUSHALL | |
volumes: | |
- ./appdata/redis:/bitnami/redis/data | |
labels: | |
- "traefik.enable=true" | |
# routers | |
- "traefik.tcp.routers.redis.rule=HostSNI(`*`)" | |
- "traefik.tcp.routers.redis.entryPoints=redis" | |
- "traefik.tcp.routers.redis.service=redis" | |
# services (needed for TCP) | |
- "traefik.tcp.services.redis.loadbalancer.server.port=6379" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment