Skip to content

Commit 814758a

Browse files
committed
add docker config
1 parent 3f09204 commit 814758a

File tree

6 files changed

+51
-256
lines changed

6 files changed

+51
-256
lines changed

backend/collaboration/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
"env-cmd": "^10.1.0",
2222
"express": "^4.21.1",
2323
"http-status-codes": "^2.3.0",
24-
"pg": "^8.13.0",
2524
"pino": "^9.4.0",
2625
"pino-http": "^10.3.0",
2726
"redis": "^4.7.0",

backend/collaboration/src/config.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,3 @@ import 'dotenv/config';
33
export const UI_HOST = process.env.PEERPREP_UI_HOST!;
44

55
export const EXPRESS_PORT = process.env.EXPRESS_PORT;
6-
7-
export const WEBSOCKET_PORT = process.env.WEBSOCKET_PORT;

backend/collaboration/src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ import { dbHealthCheck } from '@/server';
44
import server from '@/websocket';
55

66
const port = Number.parseInt(EXPRESS_PORT || '8001');
7-
const wsPort = Number.parseInt(WEBSOCKET_PORT || '8002');
87

98
const listenMessage = `App listening on port: ${port}`;
109
server.listen(port, () => {
1110
void dbHealthCheck();
1211
logger.info(listenMessage);
1312
});
14-
server.listen(wsPort, () => logger.info(`WebSocket listening on port: ${wsPort}`));

backend/collaboration/src/y-postgresql/interfaces.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

backend/collaboration/src/y-postgresql/utils.ts

Lines changed: 0 additions & 237 deletions
This file was deleted.

docker-compose.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,24 @@ services:
7676
networks:
7777
- match-db-network
7878

79+
collab-db:
80+
hostname: 'collab-db'
81+
image: postgres:16.4
82+
container_name: 'collab-db'
83+
env_file:
84+
- ./backend/collaboration/.env.local
85+
volumes:
86+
- 'collab-db-docker:${COLLAB_PGDATA}'
87+
restart: unless-stopped
88+
networks:
89+
- collab-db-network
90+
healthcheck:
91+
test: ['CMD-SHELL', 'pg_isready -U peerprep-collab-express -d collab']
92+
interval: 10s
93+
retries: 5
94+
start_period: 30s
95+
timeout: 10s
96+
7997
# Services
8098
user-service:
8199
image: 'user-express'
@@ -201,6 +219,37 @@ services:
201219
retries: 5
202220
start_period: 5s
203221

222+
collab-service:
223+
image: 'collab-express'
224+
container_name: '${COLLAB_SERVICE_NAME}'
225+
build:
226+
context: ./backend/collaboration
227+
dockerfile: express.Dockerfile
228+
target: production
229+
args:
230+
# For building with the correct env vars
231+
- port=${COLLAB_EXPRESS_PORT}
232+
env_file:
233+
- ./backend/collaboration/.env.compose
234+
environment:
235+
# Docker Compose Specific for Service Discovery
236+
- EXPRESS_DB_HOST=collab-db
237+
- EXPRESS_DB_PORT=5432
238+
- PEERPREP_UI_HOST=http://${FRONTEND_SERVICE_NAME}:${FRONTEND_PORT}
239+
depends_on:
240+
collab-db:
241+
condition: service_healthy
242+
restart: true
243+
networks:
244+
- collab-db-network
245+
- collab-ws-network
246+
healthcheck:
247+
test: wget --no-verbose --tries=1 --spider http://localhost:${COLLAB_EXPRESS_PORT}/health || exit 1
248+
interval: 30s
249+
timeout: 10s
250+
retries: 5
251+
start_period: 5s
252+
204253
# Frontend
205254
frontend:
206255
image: 'frontend'
@@ -247,6 +296,8 @@ volumes:
247296
# Redis Match server
248297
match-db-docker:
249298
external: true
299+
collab-db-docker:
300+
external: true
250301

251302
networks:
252303
# Isolated API Server Networks

0 commit comments

Comments
 (0)