Skip to content

Commit ca791a5

Browse files
authored
Merge pull request #153 from CS3219-AY2425S1/enhancement/docker-question-service
Docker for question-service
2 parents a64451e + f83d28e commit ca791a5

File tree

6 files changed

+33
-1
lines changed

6 files changed

+33
-1
lines changed

.env.sample

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Common variables
2+
BUILD_ENV=dev
3+
4+
# Question service variables
5+
QUESTION_SVC_PORT=8001
6+
QUESTION_SVC_DB_URI=

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.env

docker-compose.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
services:
2+
question-service:
3+
build:
4+
context: ./question-service
5+
target: $BUILD_ENV
6+
ports:
7+
- $QUESTION_SVC_PORT:$QUESTION_SVC_PORT
8+
environment:
9+
- PORT=$QUESTION_SVC_PORT
10+
- DB_CLOUD_URI=$QUESTION_SVC_DB_URI

question-service/.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
**/README.md
2+
**/.gitignore
3+
**/.venv
4+

question-service/.env.sample

Lines changed: 0 additions & 1 deletion
This file was deleted.

question-service/Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM python:3.12-slim AS setup
2+
WORKDIR /app
3+
COPY requirements.txt .
4+
RUN python -m venv .venv
5+
RUN .venv/bin/pip install --no-cache-dir -r requirements.txt
6+
COPY . .
7+
8+
FROM setup AS dev
9+
CMD ["sh", "-c", ".venv/bin/fastapi dev app/main.py --port ${PORT}"]
10+
11+
FROM setup AS prod
12+
CMD ["sh", "-c", ".venv/bin/fastapi run app/main.py --port ${PORT}"]

0 commit comments

Comments
 (0)