Skip to content

Commit f730597

Browse files
committed
updated dockerfile
1 parent 808c15c commit f730597

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

Dockerfile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
1+
# Build stage
12
FROM python:3.12.7 AS builder
23

34
ENV PYTHONUNBUFFERED=1 \
45
PYTHONDONTWRITEBYTECODE=1
56
WORKDIR /app
67

7-
8+
# Create and activate virtual environment, then install dependencies
89
RUN python -m venv .venv
910
COPY requirements.txt ./
1011
RUN .venv/bin/pip install -r requirements.txt
12+
13+
# Final stage
1114
FROM python:3.12.7-slim
1215
WORKDIR /app
16+
17+
# Copy virtual environment from the builder stage
1318
COPY --from=builder /app/.venv .venv/
1419
COPY . .
15-
CMD alembic upgrade heads && /app/.venv/bin/fastapi run
20+
21+
# Set PATH so the environment's executables are prioritized
22+
ENV PATH="/app/.venv/bin:$PATH"
23+
24+
# Run Alembic migrations and start FastAPI
25+
CMD ["sh", "-c", "alembic upgrade heads && fastapi run"]

0 commit comments

Comments
 (0)