-
-
Save edueo/19dab77a1437c8b4eee38cd4a046b5d3 to your computer and use it in GitHub Desktop.
Blue/Green deployment (Traefik, docker)
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
ENVIRONMENT=dev | |
OTHER_CONFIG=BLAH |
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
#!/bin/bash | |
blue=$(docker ps -f name=blue -q) | |
if test -z "$blue" | |
then | |
ENV="blue" | |
OLD="green" | |
else | |
ENV="green" | |
OLD="blue" | |
fi | |
echo "Starting "$ENV" container" | |
docker-compose pull | |
docker-compose --project-name=$ENV up -d | |
echo "Waiting..." | |
sleep 30s | |
echo "Stopping "$OLD" container" | |
docker-compose --project-name=$OLD stop |
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: | |
traefik: | |
image: "traefik:v2.1" | |
restart: unless-stopped | |
networks: | |
- webgateway | |
command: | |
- "--api.insecure=true" | |
- "--providers.docker=true" | |
- "--providers.docker.exposedbydefault=false" | |
- "--entrypoints.web.address=:80" | |
ports: | |
- "80:80" | |
- "8080:8080" | |
volumes: | |
- "/var/run/docker.sock:/var/run/docker.sock" | |
networks: | |
webgateway: | |
driver: bridge |
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: | |
membership-app: | |
image: my-app:latest | |
labels: | |
- "traefik.enable=true" | |
- "traefik.http.middlewares.test-retry.retry.attempts=3" | |
- "traefik.http.routers.membership.rule=Host(`my-app.com`)" | |
- "traefik.http.routers.membership.entrypoints=web" | |
- "traefik.http.services.membership.loadbalancer.server.port=8080" | |
- "traefik.http.services.membership.loadbalancer.healthCheck.path=/status" | |
- "traefik.http.services.membership.loadbalancer.healthCheck.interval=10s" | |
- "traefik.http.services.membership.loadbalancer.healthCheck.timeout=1s" | |
env_file: | |
- config.env | |
restart: unless-stopped | |
networks: | |
- traefik | |
networks: | |
traefik: | |
external: | |
name: traefik_webgateway |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment