-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yaml
99 lines (95 loc) · 3.44 KB
/
docker-compose.yaml
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
services:
mongodb:
# To create this service, Compose will pull the mongo
image: mongo:7.0.4
# a custom name for the MongoDB container
container_name: mongo
# Configures the container to restart automatically.
restart: always
# Volumes to persist data and initialize MongoDB
volumes:
# The named volume dbdata will persist the data stored in Mongo’s default data directory, /data/db.
# This will ensure that you don’t lose data in cases where you stop or remove containers.
- dbdata:/data/db
healthcheck:
test:
["CMD", "mongosh", "--quiet", "--eval", "db.adminCommand('ping').ok"]
interval: 1m
timeout: 10s
retries: 3
start_period: 30s
# only for the local env
mongo-express:
# Use the official mongo-express image
image: mongo-express
restart: always
container_name: mongo-express
env_file: .env
environment:
ME_CONFIG_BASICAUTH_USERNAME: ${MONGO_EXPRESS_AUTH_ADMIN}
ME_CONFIG_BASICAUTH_PASSWORD: ${MONGO_EXPRESS_AUTH_PWD}
ME_CONFIG_BASICAUTH: "true"
ME_CONFIG_MONGODB_SERVER: mongodb # Service name for MongoDB container
# Map container port 8081 to host port 8081
ports:
- 8081:8081
depends_on:
mongodb: # Ensure mongo-express starts after MongoDB is up and running
condition: service_healthy
# To build task backend image
api:
# This defines the configuration options, including the context and dockerfile,
# that will be applied when Compose builds the application image.
build:
# This defines the build context for the image build
context: ./server
dockerfile: dockerfile
args:
NODE_ENV: production
# This is the name we’ll use to refer to this image in Docker commands or to push to a Docker registry.
image: sainiabhishek/fullstack_task-api:1.1.1
container_name: api
env_file: ./server/.env
restart: always
environment:
MONGO_URI: mongodb://mongo:27017/
MONGO_DB_HOST: mongo
TOKEN_ISSUER: api.prod.saini.com
TOKEN_AUDIENCE: prod.saini.com
FRONTEND_RESET_URL: http://localhost:3000/
CORS_URL: http://localhost:3000
ports:
- 3001:3001
depends_on:
mongodb:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3001/api/v1/healthcheck"]
interval: 1m
timeout: 10s
retries: 3
start_period: 30s
# To build task frontend image
frontend:
build:
context: ./frontend
dockerfile: dockerfile
args:
NODE_ENV: production
# This is the name we’ll use to refer to this image in Docker commands or to push to a Docker registry.
image: sainiabhishek/fullstack_task-frontend:1.2.0
container_name: frontend
restart: always
environment:
APP_API_BASE_URL: http://localhost:3001/api/v1
ports:
- 3000:80
depends_on:
api:
condition: service_healthy
# Our top-level volumes key defines the volumes dbdata.
# When Docker creates volumes, the contents of the volume are stored in a part of the host filesystem, /var/lib/docker/volumes/, that’s managed by Docker.
# The contents of each volume are stored in a directory under /var/lib/docker/volumes/ and get mounted to any container that uses the volume.
# In this way, the data that our users will create will persist in the dbdata volume even if we remove and recreate the db container.
volumes:
dbdata: