Skip to content

Commit 0dd50c6

Browse files
authored
Merge pull request #155 from CS3219-AY2425S1/feature/frontend-docker
Add dockerfile for frontend and use port 8000 for question
2 parents 824c2aa + 5afa745 commit 0dd50c6

File tree

4 files changed

+35
-1
lines changed

4 files changed

+35
-1
lines changed

.env.sample

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
# Common variables
22
BUILD_ENV=dev
33

4+
# Frontend variables
5+
FRONTEND_PORT=3000
6+
47
# Question service variables
5-
QUESTION_SVC_PORT=8001
8+
QUESTION_SVC_PORT=8000
69
QUESTION_SVC_DB_URI=
710

811

docker-compose.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11
services:
2+
frontend:
3+
build:
4+
context: ./frontend
5+
target: $BUILD_ENV
6+
ports:
7+
- $FRONTEND_PORT:$FRONTEND_PORT
8+
depends_on:
9+
- question-service
10+
- user-service
11+
212
question-service:
313
build:
414
context: ./question-service

frontend/.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
.next

frontend/Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Build stage
2+
FROM node:20-alpine AS base
3+
WORKDIR /app
4+
COPY package.json yarn.lock ./
5+
RUN yarn install --frozen-lockfile
6+
7+
# Development stage
8+
FROM base AS dev
9+
COPY . .
10+
CMD ["yarn", "dev"]
11+
12+
# Production build stage
13+
FROM base AS build
14+
COPY . .
15+
RUN yarn build
16+
17+
# Production runtime stage
18+
FROM build AS prod
19+
CMD ["yarn", "start"]

0 commit comments

Comments
 (0)