-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-compose.yml
51 lines (47 loc) · 2.07 KB
/
docker-compose.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# docker-compose.yml file version
version: '2'
# Data volume for Mongo
volumes:
mongostorage:
# Services (Docker containers)
services:
# Mongo Database service
mongodb:
# Give it a name
container_name: mongodb_container
# https://hub.docker.com/r/alexpunct/mongo/
image: alexpunct/mongo:3.4
# We use mongostorage data volume and we will use the /data/db path for the database inside the container
volumes:
- mongostorage:/data/db
# Expose a MongoDB port to connect to, defined by the MONGODB_EXPOSED_PORT environment variable
# and map this port to the 27017 internal port which is what MongoDB uses
ports:
- "${MONGODB_EXPOSED_PORT}:27017"
# Passing environment variables from the host to the container.
# Our container expects the following variables (as explained here: https://hub.docker.com/r/alexpunct/mongo/)
environment:
MONGODB_ADMIN_USER: $MONGODB_ADMIN_USER
MONGODB_ADMIN_PASS: $MONGODB_ADMIN_PASS
MONGODB_APPLICATION_DATABASE: $MONGODB_APPLICATION_DATABASE
MONGODB_APPLICATION_USER: $MONGODB_APPLICATION_USER
MONGODB_APPLICATION_PASS: $MONGODB_APPLICATION_PASS
# REST API service
restapi:
# Give it a name
container_name: restapi_container
# https://hub.docker.com/r/linuxenko/mongo-rest/
image: linuxenko/mongo-rest
# The port that our API will have exposed so we can connect to
ports:
- "${REST_API_EXPOSED_PORT}:3000"
# This field creates a hosts file entry in our container that points to the mongodb service
# so we can access it with the hostname mongo as in http://mongo:3000 from this container.
# It also tells the mongodb service to allow our service to connect to it (if we hand't have exposed a port already)
# Ultimately, it makes sure that mongodb starts before our restaapi service
links:
- mongodb:mongo
# Environment variables passed to the container.
environment:
ME_CONFIG_APIKEY: $REST_API_APIKEY
ME_CONFIG_DBSTRING: "mongodb://${MONGODB_APPLICATION_USER}:${MONGODB_APPLICATION_PASS}@mongo:27017/${MONGODB_APPLICATION_DATABASE}"