-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
70 lines (52 loc) · 2.39 KB
/
docker-compose.yml
File metadata and controls
70 lines (52 loc) · 2.39 KB
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
# Version of Docker Compose config syntax
version: "3"
# Define containers here
services:
# MongoDB container
skrypt_db:
# Give container a name to easily distinguish between containers
container_name: "skrypt_db"
# Use mongo image found in Docker Hub if not already found in local repository
image: mongo
# Set environment variables in container (using `.env` file)
environment:
- MONGO_DATA_DIR=${MONGO_DATA_DIR}
- MONGO_LOG_DIR=${MONGO_LOG_DIR}
# - MONGO_INITDB_DATABASE=${MONGO_INITDB_DATABASE} # Mongo will create a few databases regardless
# - MONGO_INITDB_ROOT_USERNAME=${MONGO_INITDB_ROOT_USERNAME} # Auth is assumed when username and password are provided
# - MONGO_INITDB_ROOT_PASSWORD=${MONGO_INITDB_ROOT_PASSWORD}
# Mount `./data/db` directory on host to `/data/db` directory in container
volumes:
- db_data:/data/db
# Use port 27017 on both host and container when connecting (port 27017 is default for MongoDB)
ports:
- "27017:27017"
# Run MongoDB server with `mongod`, limit filesize for development with `--smallfiles` (not recommended for production), write log files to `/dev/null` directory with `--logpath`, and try to limit output with `--quiet` (commented out for now)
command: mongod --smallfiles --logpath=/dev/null # --quiet
# Restart MongoDB server if it fails
restart: on-failure
# Web application container
skrypt_app:
# Give container a name to easily distinguish between containers
container_name: "skrypt_app"
# Build from root of project directory where the `Dockerfile` should be
build: .
# Set environment variables in container (using `.env` file)
environment:
- NODE_ENV=${NODE_ENV}
# Mount root of host project directory to `/skrypt` directory in container
# NOTE: uncommenting the volumes config will force the container to use the
# node_modules folder on the host machine. this can cause problems if
# host is using a different architecture than the container
# volumes:
# - .:/skrypt
# Use port 3000 on both host and container when connecting
ports:
- "3000:3000"
# Start mongo container before app container (does not wait for mongo to be up and running before starting app container)
depends_on:
- skrypt_db
# Restart app if it fails
restart: on-failure
volumes:
db_data: