-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdocker-compose.yml
81 lines (75 loc) · 2.43 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# Use version 3 of docker-compose (latest at time of writing)
version: '3'
# Define the services
services:
# Set up the service for the server
app:
# Build the current directory
build: .
# Ensure that node_modules aren't unnecessarily copied
volumes:
- ./:/app
- /app/node_modules/
# Set the container name
container_name: ${SERVER_NAME}
# Let the server know that it depends on redis, so that it can connect
depends_on:
- mongo
- redis
# Connect to the barq network
networks:
- barq-net
# Define the ports on which the local machine will be able to access the server (local:container)
ports:
- "${SERVER_PORT}:${SERVER_PORT}"
# Define the environment variables based on local .env
environment:
- ENV=${ENV}
- SERVER_PORT=${SERVER_PORT}
- MONGO_URL=${MONGO_DOCKER_URL}
- MONGO_NAME=${MONGO_NAME}
- MONGO_PORT=${MONGO_PORT}
- REDIS_URL=${REDIS_DOCKER_URL}
- REDIS_PORT=${REDIS_PORT}
- STRIPE_SK=${STRIPE_SK}
# Make sure to keep restarting the server if it fails
restart: always
# Run the appropriate command for starting the server when ready
command: ./scripts/wait-for.sh ${MONGO_NAME}:${MONGO_PORT} -- npm run ${ENV}
# Set up the mongo db for the backoffice services
mongo:
# Use the official latest stable mongo image
image: mongo:4
# Set the container name
container_name: ${MONGO_NAME}
# Designate a local directory to persist data
volumes:
- ./data/${MONGO_NAME}:/data/${MONGO_NAME}
# Connect to the barq network
networks:
- barq-net
# Expose the correct port for connections
ports:
- "${MONGO_PORT}:27017"
# Make sure to keep restarting the server if it fails
restart: always
# Set up the redis cache for the frontoffice services (eventually)
redis:
# Use the official image of redis 5 (latest version at time of writing)
image: redis:5
# Set the container_name to have easy access to the cache
container_name: ${REDIS_NAME}
# Set the volumes for potentially persisting data
volumes:
- ./data/${REDIS_NAME}:/data/${REDIS_NAME}
# Set the network mode to bridge to prevent making new networks
networks:
- barq-net
# Set the ports
ports:
- "${REDIS_PORT}:6379"
# Make sure to keep restarting the server if it fails
restart: always
networks:
barq-net:
driver: bridge