Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker for question-service #153

Merged
merged 3 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Common variables
BUILD_ENV=dev

# Question service variables
QUESTION_SVC_PORT=8001
QUESTION_SVC_DB_URI=
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.env
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
services:
question-service:
build:
context: ./question-service
target: $BUILD_ENV
ports:
- $QUESTION_SVC_PORT:$QUESTION_SVC_PORT
environment:
- PORT=$QUESTION_SVC_PORT
- DB_CLOUD_URI=$QUESTION_SVC_DB_URI
4 changes: 4 additions & 0 deletions question-service/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
**/README.md
**/.gitignore
**/.venv

1 change: 0 additions & 1 deletion question-service/.env.sample

This file was deleted.

12 changes: 12 additions & 0 deletions question-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM python:3.12-slim AS setup
WORKDIR /app
COPY requirements.txt .
RUN python -m venv .venv
RUN .venv/bin/pip install --no-cache-dir -r requirements.txt
COPY . .

FROM setup AS dev
CMD ["sh", "-c", ".venv/bin/fastapi dev app/main.py --port ${PORT}"]

FROM setup AS prod
CMD ["sh", "-c", ".venv/bin/fastapi run app/main.py --port ${PORT}"]