Skip to content

Instantly share code, notes, and snippets.

@timjonesdev
Created August 22, 2019 04:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timjonesdev/d756b5b01dc1a1c0fabaca90116f3f82 to your computer and use it in GitHub Desktop.
Save timjonesdev/d756b5b01dc1a1c0fabaca90116f3f82 to your computer and use it in GitHub Desktop.
version: "3.0"
services:
# Core Spring Boot Application
app:
build:
context: ..
dockerfile: ./Dockerfile
image: "rx_mongo_example"
env_file:
- .env
links:
- mongo
ports:
- 8080:8080
# MongoDB - Reactive Persistence
mongo:
build:
context: mongo
dockerfile: Dockerfile
image: "mongodb"
hostname: mongo
ports:
- 27017:27017
volumes:
- mongodata:/data/db
env_file:
- mongo/.env
# The mongo-seed container is just for waiting until the main mongo container is done setting its replicaset up
# and then initializing data.
mongo-seed:
build:
context: mongo_seed
dockerfile: Dockerfile
# ping the main mongo instance relentlessly until the connection is ready, then wait, then run an initialize data script to populate data.
command: bash -c "until mongo mongo:27017/fantasy_db; do echo 'Waiting for Mongo to be ready...'; sleep 1; done; sleep 3; mongo mongo:27017/fantasy_db init.js; "
links:
- mongo
volumes:
mongodata:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment