Skip to content

Commit 89a8a03

Browse files
committed
PEER-236: Docker compose, nginx configs
1 parent a460759 commit 89a8a03

File tree

8 files changed

+56
-36
lines changed

8 files changed

+56
-36
lines changed

backend/chat/.env.compose

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
EXPRESS_PORT=9005
2-
EXPRESS_DB_HOST="chat-db"
2+
EXPRESS_DB_HOST=chat-db
33
EXPRESS_DB_PORT=5435
4-
POSTGRES_DB="chat"
5-
POSTGRES_USER="peerprep-chat-express"
6-
POSTGRES_PASSWORD="Xk8qEcEI2sizjfEn/lF6mLqiyBECjIHY3q6sdXf9poQ="
4+
POSTGRES_DB=chat
5+
POSTGRES_USER=peerprep-chat-express
6+
POSTGRES_PASSWORD=Xk8qEcEI2sizjfEn/lF6mLqiyBECjIHY3q6sdXf9poQ=
77
PGDATA="/data/chat-db"

backend/chat/.env.local

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ EXPRESS_DB_HOST=localhost
55
EXPRESS_DB_PORT=5435
66
POSTGRES_DB=chat
77
POSTGRES_USER=peerprep-chat-express
8-
POSTGRES_PASSWORD='Xk8qEcEI2sizjfEn/lF6mLqiyBECjIHY3q6sdXf9poQ='
8+
POSTGRES_PASSWORD=Xk8qEcEI2sizjfEn/lF6mLqiyBECjIHY3q6sdXf9poQ=
99
PGDATA=/data/chat-db

backend/chat/entrypoint.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
3+
# Drizzle will handle its own logic to remove conflicts
4+
npm run db:prod:migrate
5+
6+
# Checks admin table and will not seed if data exists
7+
npm run db:prod:seed
8+
9+
rm -rf drizzle src tsconfig.json
10+
11+
npm uninstall tsx drizzle-kit
12+
13+
npm run start

backend/chat/express.Dockerfile

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
FROM node:lts-alpine AS build
2-
WORKDIR /data/collab-express
2+
WORKDIR /data/chat-express
33
COPY package*.json ./
44
RUN npm install
5-
ARG env
65
COPY . .
76
RUN npm run build
87

98
FROM node:lts-alpine AS production
10-
WORKDIR /data/collab-express
11-
COPY --from=build /data/collab-express/package*.json ./
12-
COPY --from=build --chown=node:node /data/collab-express/dist ./dist
9+
WORKDIR /data/chat-express
10+
COPY --from=build /data/chat-express/package*.json ./
11+
COPY --from=build --chown=node:node /data/chat-express/dist ./dist
1312

1413
RUN npm ci --omit=dev
1514

16-
RUN sed -i 's|./ws|ws|g' ./dist/ws.js
17-
15+
COPY src/lib/db ./src/lib/db
16+
COPY src/lib/utils ./src/lib/utils
17+
COPY src/config.ts ./src
18+
COPY tsconfig.json .
1819
COPY entrypoint.sh .
1920

2021
ARG port

backend/chat/package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,26 @@
2222
"license": "ISC",
2323
"description": "",
2424
"dependencies": {
25+
"dotenv": "^16.4.5",
2526
"drizzle-orm": "^0.33.0",
2627
"express": "^4.21.0",
2728
"http": "^0.0.1-security",
2829
"http-status-codes": "^2.3.0",
2930
"pino": "^9.4.0",
3031
"pino-http": "^10.3.0",
3132
"postgres": "^3.4.4",
32-
"socket.io": "^4.8.1"
33+
"socket.io": "^4.8.1",
34+
"tsc-alias": "^1.8.10",
35+
"tsx": "^4.19.1"
3336
},
3437
"devDependencies": {
3538
"@types/express": "^4.17.21",
3639
"@types/node": "^22.5.5",
3740
"drizzle-kit": "^0.24.2",
3841
"nodemon": "^3.1.4",
3942
"pino-pretty": "^11.2.2",
40-
"ts-node": "^10.9.2"
43+
"ts-node": "^10.9.2",
44+
"tsx": "^4.19.1",
45+
"typescript": "^5.6.3"
4146
}
4247
}

docker-compose.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ services:
7070
build:
7171
context: ./backend/chat/src/lib/db
7272
env_file:
73-
- ./backend/chat/.env.local
73+
- ./backend/chat/.env.compose
7474
volumes:
7575
- 'chat-db-docker:${CHAT_PGDATA}'
7676
# - ./init.sql:/docker-entrypoint-initdb.d/init.sql
@@ -246,7 +246,7 @@ services:
246246
environment:
247247
# Docker Compose Specific for Service Discovery
248248
- EXPRESS_DB_HOST=chat-db
249-
- EXPRESS_DB_PORT=5435
249+
- EXPRESS_DB_PORT=5432
250250
- PEERPREP_UI_HOST=http://${FRONTEND_SERVICE_NAME}:${FRONTEND_PORT}
251251
depends_on:
252252
chat-db:
@@ -282,6 +282,7 @@ services:
282282
- VITE_COLLAB_SERVICE=http://${COLLAB_SERVICE_NAME}:${COLLAB_EXPRESS_PORT}
283283
- VITE_COLLAB_WS=ws://${COLLAB_SERVICE_NAME}:${COLLAB_EXPRESS_PORT}
284284
- VITE_MATCHING_SERVICE=http://${MATCHING_SERVICE_NAME}:${MATCHING_EXPRESS_PORT}
285+
- VITE_CHAT_SERVICE=http://${CHAT_SERVICE_NAME}:${CHAT_EXPRESS_PORT}
285286
- FRONTEND_PORT=${FRONTEND_PORT}
286287
depends_on:
287288
user-service:
@@ -298,6 +299,7 @@ services:
298299
- question-api-network
299300
- match-api-network
300301
- collab-api-network
302+
- chat-api-network
301303

302304
volumes:
303305
# Persistent Volumes for Databases

frontend/nginx.conf.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ server {
7070
proxy_set_header X-Forwarded-Proto $scheme;
7171
}
7272

73-
location /matching-socket/ {
73+
location /chat-socket/ {
7474
proxy_pass ${VITE_CHAT_SERVICE};
7575
proxy_http_version 1.1;
7676
proxy_set_header Upgrade $http_upgrade;

package-lock.json

Lines changed: 18 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)