Created
August 4, 2018 21:33
-
-
Save itayadler/2829d2410b1e0a22713fda325df11e82 to your computer and use it in GitHub Desktop.
A docker-compose for a client/api/db+migrations app
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: '2.1' | |
services: | |
api: | |
build: | |
context: ./api/ | |
command: /usr/app/node_modules/.bin/nodemon index.js | |
volumes: | |
- ./api/:/usr/app | |
- /usr/app/node_modules | |
depends_on: | |
db-migrator: | |
condition: service_healthy | |
db: | |
condition: service_healthy | |
environment: | |
- DATABASE_URL=postgres://postgres:example@db/ | |
- DATABASE_SCHEMA=app_development | |
- NODE_ENV=development | |
- CHOKIDAR_USEPOLLING=true | |
labels: | |
- "traefik.frontend.rule=Host:api.docker.localhost" | |
- "traefik.port=4000" | |
client: | |
build: | |
context: ./client/ | |
command: npm start | |
volumes: | |
- ./client/:/usr/app | |
- /usr/app/node_modules | |
labels: | |
- "traefik.frontend.rule=Host:client.docker.localhost" | |
- "traefik.port=3000" | |
db: | |
image: mdillon/postgis:9.6 | |
restart: always | |
healthcheck: | |
test: ["CMD-SHELL", "pg_isready -U postgres"] | |
interval: 10s | |
timeout: 5s | |
retries: 5 | |
environment: | |
POSTGRES_USERNAME: postgres | |
POSTGRES_PASSWORD: example | |
volumes: | |
- postgres-data:/var/lib/postgresql/data | |
expose: | |
- 5432 | |
labels: | |
- "traefik.backend=db" | |
- "traefik.frontend.rule=Host:db.docker.localhost" | |
- "traefik.port=5432" | |
db-migrator: | |
image: boxfuse/flyway | |
command: -url=jdbc:postgresql://db:5432/ -user=postgres -password=example migrate | |
healthcheck: | |
test: ["CMD-SHELL", "ls"] | |
interval: 10s | |
timeout: 5s | |
retries: 5 | |
volumes: | |
- ./api/migrations:/flyway/sql | |
depends_on: | |
- db | |
reverse-proxy: | |
image: traefik | |
command: --api --docker # Enables the web UI and tells Træfik to listen to docker | |
ports: | |
- "80:80" | |
- "8080:8080" # The Web UI (enabled by --api) | |
volumes: | |
- /var/run/docker.sock:/var/run/docker.sock # So that Traefik can listen to the Docker events | |
volumes: | |
postgres-data: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment