Skip to content

Commit 13ae030

Browse files
committed
Add production docker compose for API Gateway
1 parent cd5f85d commit 13ae030

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

api_gateway/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
FROM node:18
1+
FROM node:18-alpine
22
WORKDIR /usr/src/app
33
COPY package*.json ./
44
COPY tsconfig.json ./
55
RUN npm install
66
# RUN npm ci --omit=dev
77

88
COPY . .
9-
EXPOSE 8000
9+
EXPOSE 7998-8000
1010
CMD ["npm", "run", "start"]

api_gateway/Dockerfile.prod

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM node:18-alpine AS builder
2+
3+
WORKDIR /app
4+
COPY package*.json ./
5+
RUN npm ci
6+
COPY . .
7+
RUN npm run build
8+
9+
# Stage 2: Setup the production environment
10+
FROM node:18-alpine
11+
WORKDIR /usr/src/app
12+
COPY package*.json ./
13+
RUN npm ci --only=production
14+
COPY --from=builder /app/dist ./dist
15+
EXPOSE 7998-8080
16+
17+
# Command to run the application
18+
CMD ["node", "./dist/index.js"]

docker-compose.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,25 @@ services:
1111
- REACT_APP_ENV_TYPE=prod
1212
ports:
1313
- "80:80"
14+
15+
api-gateway:
16+
container_name: api-gateway
17+
image: asia-southeast1-docker.pkg.dev/cs3219-400714/peerprep/api-gateway:latest
18+
build:
19+
context: ./api_gateway
20+
dockerfile: Dockerfile.prod
21+
environment:
22+
SECRET_KEY: ${SECRET_KEY}
23+
ENV_TYPE: docker
24+
ports:
25+
- "8000:8000"
26+
- "7999:7999"
27+
- "7998:7998"
28+
depends_on:
29+
- question-service
30+
- user-service
31+
- matching-service
32+
- collab-service
1433

1534
question-service:
1635
container_name: question-service
@@ -48,6 +67,7 @@ services:
4867
environment:
4968
PORT: 8081
5069
SECRET_KEY: ${SECRET_KEY}
70+
DATABASE_URL: ${DATABASE_URL}
5171
ports:
5272
- "8081:8081"
5373
depends_on:

0 commit comments

Comments
 (0)