-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yml
129 lines (122 loc) · 3.63 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
networks:
clients-app-network:
driver: bridge
services:
# Service: MongoDB database
# Description: This service is used to run the MongoDB database that houses our data.
mongodb:
build:
context: ./.docker/mongodb
container_name: "${APP_NAME}-database"
environment:
- MONGO_INITDB_ROOT_USERNAME=${MONGO_INITDB_ROOT_USERNAME}
- MONGO_INITDB_ROOT_PASSWORD=${MONGO_INITDB_ROOT_PASSWORD}
- MONGO_INITDB_DATABASE=${MONGO_INITDB_DATABASE}
networks:
- ${APP_NAME}-network
ports:
- "27017:27017"
restart: on-failure
# keep the container running, see: https://stackoverflow.com/questions/44884719/exited-with-code-0-docker
tty: true
volumes:
- ./.docker/mongodb/init.d:/docker-entrypoint-initdb.d/
- ./.docker/mongodb/etc/mongod.conf:/etc/mongod.conf
- ./.docker/mongodb/logs/mongod.log:/var/log/mongodb/mongod.log
- db-data:/data/db
# Service: OpenSSL
# Description: This service is used to generate SSL certificates for our application.
openssl:
build:
context: ./.docker/openssl
container_name: "${APP_NAME}-openssl"
networks:
- ${APP_NAME}-network
volumes:
- clientsapp-certs-data:/etc/ssl/certs/clientsapp.local/
# Service: Nginx webserver
# Description: Nginx will be used as a reverse proxy to serve our application.
webserver:
build:
context: ./.docker/nginx
container_name: "${APP_NAME}-webserver"
depends_on:
- express
- mongodb
- openssl
- app
# Ports to be exposed
ports:
- "80:80"
- "443:443"
- "5173:5173"
- "8080:8080"
- "8443:8443"
networks:
- ${APP_NAME}-network
volumes:
# Files
- ./.docker/nginx/etc/nginx.conf:/etc/nginx/nginx.conf
# Directories
- ./.docker/nginx/etc/conf.d/:/etc/nginx/conf.d/
- ./.docker/nginx/etc/snippets/:/etc/nginx/snippets/
- ./.docker/nginx/logs/:/var/log/nginx/
- ./app/:/var/www/html/
# Volumes
- clientsapp-certs-data:/etc/ssl/certs/clientsapp.local/
# Service: Express Server
# Description: This service is used to run the Express Node.js server.
express:
build:
context: ./api
container_name: "${APP_NAME}-express"
depends_on:
- mongodb
environment:
# Node.js Express init variables
- PORT=${EXPRESS_PORT}
# MongoDB init variables
- MONGO_INITDB_ROOT_USERNAME=${MONGO_INITDB_ROOT_USERNAME}
- MONGO_INITDB_ROOT_PASSWORD=${MONGO_INITDB_ROOT_PASSWORD}
- MONGO_INITDB_DATABASE=${MONGO_INITDB_DATABASE}
# MongoDB variables
- MONGO_DB=${MONGO_DB}
- MONGO_HOST=${MONGO_HOST}
- MONGO_PASS=${MONGO_PASS}
- MONGO_PORT=${MONGO_PORT}
- MONGO_USER=${MONGO_USER}
networks:
- ${APP_NAME}-network
restart: on-failure
volumes:
- ./api:/usr/src/app
- ./api/node_modules/:/usr/src/app/node_modules/
- node_modules:/usr/src/app/node_modules/
# Volumes
- clientsapp-certs-data:/etc/ssl/certs/clientsapp.local/
# Service: React App
# Description: This service is used to run the React client.
app:
build:
context: ./app
container_name: "${APP_NAME}-app"
environment:
# Node.js Express init variables
- PORT=${REACT_PORT}
networks:
- ${APP_NAME}-network
restart: on-failure
volumes:
- ./app:/usr/src/app
- ./app/node_modules/:/usr/src/app/node_modules/
- app_node_modules:/usr/src/app/node_modules/
version: "3.9"
volumes:
db-data:
driver: local
clientsapp-certs-data:
driver: local
node_modules:
driver: local
app_node_modules:
driver: local