-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yml
210 lines (201 loc) · 6.81 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
version: "3.8"
# This docker-compose file is used to configure services for the Starter project.
# The services configured here include that of an API server, a UI frontend, and MongoDB.
# The API service uses a Dockerfile located in the docker-assets/api-v1/ folder to create the image.
# It's command line arguments include a workdir to the API work directory, a Node version to use, and a
# Nestjs version to use. Build variables are also set in the environment section providing access to AWS services,
# ports and MongoDB credentials.
# The front service uses a Dockerfile located in the docker-assets/ui-v1/ folder to create the image. It's command
# line arguments include a workdir to the UI work directory, a Node version to use, and an Angular version to use.
# Build variables are also set in the environment section providing access to ports and Node environment.
# The mongo service uses a .env file located in the docker-assets/mongo/ folder to configure environment variables.
# It's command line argument include a Mongo version to use and a timezone to use.
# Volumes and networks are also configured allowing for persistent data storage and connectivity between containers.
services:
# API Service
api:
image: starter/api:dev
container_name: starter-api-dev
hostname: starter-api
command: /bin/bash /init.sh
build:
context: docker-assets/api/
args:
workdir: ${API_WORKDIR}
node_version: ${USE_NODE_VERSION:-16.20.0}
node_env: ${NODE_ENV:-development}
nestjs_version: ${NESTJS_CLI_VERSION:-latest}
mongo_version: ${MONGO_VERSION:-6.0}
debug: ${DEBUG:-yes}
passport_auth_strategy: ${PASSPORT_AUTH_STRATEGY:-local}
tz: ${TZ:-Etc/UTC}
environment:
NODE_VERSION: ${USE_NODE_VERSION}
API_PORT: ${API_PORT_CONT:-3000}
MONGO_PORT: ${MONGO_PORT_CONT:-27017}
MONGO_HOST: ${MONGO_HOST:-mongo}-${KEY_LEN:-4096}
MONGO_USER: ${MONGO_USER_NAME:-starter_api}
MONGO_PASS: ${MONGO_USER_PASS?Environment variable MONGO_USER_PASS not specified}
MONGO_DB: ${MONGO_DB:-starter}
MONGO_URL_PARAMS: "?appName=${MONGO_APP_NAME}&authSource=${MONGO_DB:-starter}&appName=${MONGO_APP_NAME}&tls=true&tlsAllowInvalidCertificates=true&retryWrites=true&w=majority&keepAlive=true&authMechanism=DEFAULT"
MONGO_SECURE: ${MONGO_SECURE:-yes}
SERVERLESS: ${API_SERVERLESS:-no}
tty: true
volumes:
- ./apps/api:${API_WORKDIR}
ports:
- "${API_PORT_HOST:-3000}:${API_PORT_CONT:-3000}"
# NodeJS debugger port
- "9229:9229"
depends_on:
- mongo
- redis
- mysql
networks:
- starternet
# MongoDB Service
mongo:
image: starter/mongo:${MONGO_VERSION}
container_name: starter-mongo
hostname: ${MONGO_HOST}-${KEY_LEN:-4096}
command: mongod --config /etc/mongod.conf --bind_ip ${MONGO_IP:-0.0.0.0}
build:
context: ./docker-assets/mongo/
args:
mongo_version: ${MONGO_VERSION}
debug: ${DEBUG:-yes}
port: ${MONGO_PORT_CONT:-27017}
data_db: ${MONGO_DB:?Environment variable MONGO_DB not specified}
admin_db: ${MONGO_ADMIN_DB}
root_user: ${MONGO_ROOT_USER:-admin}
root_pass: ${MONGO_ROOT_PASS:?Environment variable MONGO_ROOT_PASS not defined}
user: ${MONGO_USER_NAME}
pass: ${MONGO_USER_PASS:?Environment variable MONGO_USER_PASS not defined}
telemetry: ${MONGO_TELEMETRY:-yes}
tz: ${TZ:-Etc/UTC}
max_map_count: ${MONGO_VM_MAX_MAP_COUNT:-102400}
environment:
SECURE: ${MONGO_SECURE:-no}
MONGO_HOST: ${MONGO_HOST}-${KEY_LEN:-4096}
MONGO_DB: ${MONGO_DB}
MONGO_URL_PARAMS: ${MONGO_URL_PARAMS}
MONGO_USER: ${MONGO_USER_NAME}
MONGO_PASS: ${MONGO_USER_PASS:?Environment variable MONGO_USER_PASS not defined}
ulimits:
nproc: 65535
nofile:
soft: 64000
hard: 128000
volumes:
- data_db_mongodb:/data/db/
- var_log_mongodb:/var/log/mongodb/
- mongodb_ssl:/data/ssl/:ro
- ./docker-assets/mongo/mongod.conf.yml:/etc/mongod.conf:ro
ports:
- "${MONGO_PORT_HOST:-27017}:${MONGO_PORT_CONT:-27017}"
networks:
- starternet
restart: no
depends_on:
- ca
user: mongodb:mongodb
# MySQL Database Service
mysql:
hostname: starter-mysql
container_name: starter-mysql
image: starter/mysql:${MYSQL_VERSION:-8.0}
build:
context: ./docker-assets/mysql/
args:
tz: ${TZ:-Etc/UTC}
mysql_version: ${MYSQL_VERSION:-8.0}
environment:
MYSQL_ROOT_USER: ${MYSQL_ROOT_USER:?Environment variable MYSQL_ROOT_USER not defined}
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASS:?Environment variable MYSQL_ROOT_PASS not defined}
volumes:
- ./docker-assets/mysql/my.cnf:/etc/alternatives/my.cnf
- ./docker-assets/mysql/log/:/var/log/mysql
- var_lib_mysql:/var/lib/mysql
ports:
- "${MYSQL_PORT_HOST:-3306}:${MYSQL_PORT_CONTAINER:-3306}"
restart: no
networks:
- starternet
# Redis Caching Service
redis:
image: starter/redis:${REDIS_VERSION}
hostname: starter-redis
container_name: starter-redis
build:
context: ./docker-assets/redis/
args:
tz: ${TZ:-Etc/UTC}
sysctls:
net.core.somaxconn: 1024
command: /bin/bash /init.sh
ports:
- "${REDIS_PORT_HOST:-6379}:${REDIS_PORT_CONTAINER:-6379}"
volumes:
- redis_data_bases:/data/bases
- ./docker-assets/redis/redis.conf:/usr/local/etc/redis/redis.conf
networks:
- starternet
restart: no
depends_on:
- mongo
- mysql
# UI Frontend Service
ui:
image: starter/ui:dev
container_name: starter-ui-dev
command: /bin/bash /init.sh
build:
context: ./docker-assets/ui/
args:
workdir: ${UI_WORKDIR}
tz: ${TZ:-Etc/UTC}
angular_version: ${ANGULAR_CLI_VERSION:-latest}
node_version: ${USE_NODE_VERSION:-16.20.0}
debug: ${DEBUG:-yes}
environment:
NODE_ENV: ${NODE_ENV:-development}
SERVERLESS: ${UI_SERVERLESS:-no}
tty: true
volumes:
- ./apps/ui:${UI_WORKDIR}
ports:
- "4000:4000"
- "4200:4200"
- "4300:4300"
- "9222:9222"
depends_on:
- api
networks:
- starternet
ca:
image: starter/openssl
container_name: starter-ca
build:
context: ./docker-assets/certs/
args:
debug: ${DEBUG:-yes}
key_len: ${KEY_LEN:-4096}
days: ${CERT_DAYS:-365}
ca_cn: ${CA_ORG_CN:-CAuth}
server_cn: ${MONGO_HOST:-mongo}-${KEY_LEN:-4096}
volumes:
- mongodb_ssl:/etc/ssl/mongodb/
# Specify volumes
volumes:
data_db_mongodb:
var_log_mongodb:
redis_data_bases:
var_lib_mysql:
mongodb_ssl:
# Specify networks
networks:
starternet:
ipam:
driver: default
config:
- subnet: 172.16.50.0/24