Skip to content

Instantly share code, notes, and snippets.

@jmarcos-cano
Last active October 15, 2019 23:39
Show Gist options
  • Save jmarcos-cano/a434c70f4d287854b63c0accc6ebf7a9 to your computer and use it in GitHub Desktop.
Save jmarcos-cano/a434c70f4d287854b63c0accc6ebf7a9 to your computer and use it in GitHub Desktop.
simple docker-compose
version: "3.5"
services:
web:
image: ${IMAGE_NAME:-mcano/docker:intro}
environment:
- REDIS_HOST=redis
- FOO=${FOO:-BAR}
ports:
- target: 5000
published: 5000
networks:
- skynet
redis:
image: "redis:alpine"
deploy:
replicas: 1
networks:
skynet:
networks:
skynet:
version: "3.5"
networks:
skynet:
services:
web:
image: ${IMAGE_NAME:-mcano/docker:intro}
environment:
- REDIS_HOST=redis
- DOCKER_SERVICE_NAME={{.Service.Name}}.{{.Task.Slot}}
- FOO=${FOO:-BAR}
ports:
- target: 5000
published: 5000
networks:
- skynet
# adds self-healing availability
healthcheck:
test: wget -O- http://localhost:5000/healthz
interval: 30s
timeout: 10s
retries: 3
start_period: 5s
deploy:
replicas: ${DEPLOYMENT_REPLICAS:-3}
restart_policy:
# restart under any condition
condition: any
update_config:
# update one task at a time
parallelism: 1
# update after 10s passed and task ainer is healthy
delay: 10s
# spin up a new container first
order: start-first
resources:
# hard limits
limits:
# 50% of CPU time
cpus: '0.50'
# up to 200 MB
memory: 200M
# cgroups
# at least reserve this resources
reservations:
cpus: '0.25'
memory: 10M
redis:
image: "redis:alpine"
deploy:
replicas: 1
networks:
skynet:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment