File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change 1+ # Build stage
12FROM python:3.12.7 AS builder
23
34ENV PYTHONUNBUFFERED=1 \
45 PYTHONDONTWRITEBYTECODE=1
56WORKDIR /app
67
7-
8+ # Create and activate virtual environment, then install dependencies
89RUN python -m venv .venv
910COPY requirements.txt ./
1011RUN .venv/bin/pip install -r requirements.txt
12+
13+ # Final stage
1114FROM python:3.12.7-slim
1215WORKDIR /app
16+
17+ # Copy virtual environment from the builder stage
1318COPY --from=builder /app/.venv .venv/
1419COPY . .
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" ]
You can’t perform that action at this time.
0 commit comments