Skip to content

Instantly share code, notes, and snippets.

@svenvarkel
Last active October 7, 2019 18:57
Show Gist options
  • Select an option

  • Save svenvarkel/a8562ef581f935a01bb96fd291167891 to your computer and use it in GitHub Desktop.

Select an option

Save svenvarkel/a8562ef581f935a01bb96fd291167891 to your computer and use it in GitHub Desktop.
docker-compose stack for SailsJS API with ReactJS frontend app on top of MongoDB, Redis and Nginx
version: "3.7"
services:
rabbitmq:
image: rabbitmq:3-management
environment:
RABBITMQ_DEFAULT_VHOST: "/myproject"
RABBITMQ_DEFAULT_USER: "dev"
RABBITMQ_DEFAULT_PASS: "dev"
volumes:
- type: volume
source: rabbitmq
target: /var/lib/rabbitmq/mnesia
ports:
- "5671:5671"
- "5672:5672"
- "25672:25672"
networks:
- overlay
redis:
image: redis:5.0.5
volumes:
- type: volume
source: redis
target: /data
ports:
- "6379:6379"
command: redis-server --appendonly yes
networks:
- overlay
mongodb:
image: mongo:4.2
ports:
- "27017:27017"
environment:
MONGO_INITDB_DATABASE: "admin"
MONGO_INITDB_ROOT_USERNAME: "root"
MONGO_INITDB_ROOT_PASSWORD: "root"
volumes:
- type: bind
source: ./services/mongodb/docker-entrypoint-initdb.d
target: /docker-entrypoint-initdb.d
- type: volume
source: mongodb
target: /data
networks:
- overlay
api:
build: ./api
image: myproject-api:latest
ports:
- 1337:1337
- 9337:9337
environment:
PORT: 1337
DEBUG_PORT: 9337
WAIT_HOSTS: rabbitmq:5672,mongodb:27017,redis:6379
env_file:
- ./api/.env
volumes:
- type: bind
source: ./api/api
target: /var/app/current/api
- type: bind
source: ./api/config
target: /var/app/current/config
- type: bind
source: ./api/test
target: /var/app/current/test
networks:
- overlay
depends_on:
- "rabbitmq"
- "mongodb"
- "redis"
app:
build: ./web
image: myproject-app:latest
ports:
- 3000:3000
environment:
REACT_APP_API_URL: http://api.myproject.local
volumes:
- type: bind
source: ./web/src
target: /var/app/current/src
- type: bind
source: ./web/public
target: /var/app/current/public
networks:
- overlay
depends_on:
- "api"
nginx:
build: ./services/nginx
image: nginx-wait:latest
restart: on-failure
environment:
WAIT_HOSTS: api:1337,app:3000
volumes:
- type: bind
source: ./services/nginx/conf.d
target: /etc/nginx/conf.d
- type: bind
source: ./web/build
target: /srv/webroot
- type: bind
source: ./services/var/log/nginx
target: /var/log/nginx
ports:
- 80:80
networks:
- overlay
depends_on:
- "api"
- "app"
networks:
overlay:
driver: overlay
volumes:
rabbitmq:
redis:
mongodb:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment