Created
September 13, 2019 16:10
-
-
Save kanzitelli/449f09fa4ce43bc68a774deb4a1b19da to your computer and use it in GitHub Desktop.
Docker Compose file for Traefik v2.0 deployed on Digital Ocean with https available
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' | |
services: | |
reverse-proxy: | |
image: traefik:v2.0 | |
restart: always | |
container_name: traefik | |
command: | |
- "--api=true" | |
- "--providers.docker=true" | |
- "--providers.docker.exposedbydefault=false" | |
- "--entrypoints.http.address=:80" | |
- "--entrypoints.https.address=:443" | |
- "--certificatesresolvers.mydnschallenge.acme.dnschallenge=true" | |
- "--certificatesresolvers.mydnschallenge.acme.dnschallenge.provider=digitalocean" | |
- "--certificatesresolvers.mydnschallenge.acme.email=email@your-domain.com" | |
- "--certificatesresolvers.mydnschallenge.acme.storage=/acme.json" | |
environment: | |
- DO_AUTH_TOKEN=${DO_AUTH_TOKEN} | |
ports: | |
- "80:80" | |
- "443:443" | |
- "6969:8080" | |
volumes: | |
- /var/run/docker.sock:/var/run/docker.sock | |
- ../acme/acme.json:/acme.json | |
api: | |
build: ./api | |
restart: always | |
container_name: api | |
environment: | |
- API_DEBUGMODE=${API_GIN_DEBUG_MODE} | |
- API_MONGODBNAME=${MONGO_DB_NAME} | |
- API_MONGODBURL=mongodb://${MONGO_DB_USER}:${MONGO_DB_PSWD}@mongo:27017/${MONGO_DB_NAME} | |
depends_on: | |
- mongo | |
labels: | |
- "traefik.enable=true" | |
- "traefik.http.routers.api.rule=Host(`api.${DOMAIN_NAME}`)" | |
- "traefik.http.routers.api.entryPoints=http" | |
- "traefik.http.routers.api.middlewares=https_redirect" | |
- "traefik.http.middlewares.https_redirect.redirectscheme.scheme=https" | |
- "traefik.http.routers.api_tls.rule=Host(`api.${DOMAIN_NAME}`)" | |
- "traefik.http.routers.api_tls.entryPoints=https" | |
- "traefik.http.routers.api_tls.tls.certresolver=mydnschallenge" | |
mongo: | |
image: mongo | |
restart: always | |
container_name: mongo | |
environment: | |
- MONGO_INITDB_ROOT_USERNAME=${MONGO_ADMIN} | |
- MONGO_INITDB_ROOT_PASSWORD=${MONGO_ADMIN_PSWD} | |
volumes: | |
- ../appdata/db:/data/db | |
labels: | |
- "traefik.enable=false" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment