@@ -4,7 +4,7 @@ services:
44 # Databases
55 user-db :
66 hostname : ' user-db'
7- image : postgres:16.4
7+ image : ' postgres:16.4'
88 container_name : ' user-db'
99 build :
1010 context : ./backend/user/src/lib/db
@@ -55,8 +55,6 @@ services:
5555 restart : unless-stopped
5656 networks :
5757 - question-db-network
58- ports :
59- - 5433:5432
6058 healthcheck :
6159 test : ['CMD-SHELL', 'pg_isready -U peerprep-qn-express -d question']
6260 interval : 10s
@@ -75,8 +73,6 @@ services:
7573 args :
7674 # For building with the correct env vars
7775 - port=${USER_EXPRESS_PORT}
78- ports :
79- - ' 9001:${USER_EXPRESS_PORT}'
8076 env_file :
8177 - ./backend/user/.env.compose
8278 environment :
@@ -91,12 +87,42 @@ services:
9187 - user-db-network
9288 - user-api-network
9389 healthcheck :
94- test : wget --no-verbose --tries=1 --spider http://localhost:9001 /health || exit 1
90+ test : wget --no-verbose --tries=1 --spider http://localhost:${USER_EXPRESS_PORT} /health || exit 1
9591 interval : 30s
9692 timeout : 10s
9793 retries : 5
9894 start_period : 5s
9995
96+ question-service :
97+ image : " question-express"
98+ container_name : ' ${QUESTION_SERVICE_NAME}'
99+ build :
100+ context : ./backend/question
101+ dockerfile : express.Dockerfile
102+ target : production
103+ args :
104+ # For building with the correct env vars
105+ - port=${QUESTION_EXPRESS_PORT}
106+ env_file :
107+ - ./backend/question/.env.compose
108+ environment :
109+ # Docker Compose Specific for Service Discovery
110+ - EXPRESS_DB_HOST=question-db
111+ - EXPRESS_DB_PORT=5432
112+ depends_on :
113+ question-db :
114+ condition : service_healthy
115+ restart : true
116+ networks :
117+ - question-db-network
118+ - question-api-network
119+ healthcheck :
120+ test : wget --no-verbose --tries=1 --spider http://localhost:${QUESTION_EXPRESS_PORT}/health || exit 1
121+ interval : 30s
122+ timeout : 10s
123+ retries : 5
124+ start_period : 5s
125+
100126 # Frontend
101127
102128 frontend :
@@ -113,13 +139,15 @@ services:
113139 - ./frontend/.env.compose
114140 environment :
115141 - VITE_USER_SERVICE=http://${USER_SERVICE_NAME}:${USER_EXPRESS_PORT}
116- # #to remove localhost once integrating question
117- - VITE_QUESTION_SERVICE=http://host.docker.internal:${QUESTION_EXPRESS_PORT}
142+ - VITE_QUESTION_SERVICE=http://${QUESTION_SERVICE_NAME}:${QUESTION_EXPRESS_PORT}
118143 - FRONTEND_PORT=${FRONTEND_PORT}
119144 depends_on :
120145 user-service :
121146 condition : service_healthy
122147 restart : true
148+ question-service :
149+ condition : service_healthy
150+ restart : true
123151 networks :
124152 - user-api-network
125153 - question-api-network
0 commit comments