-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprod.Dockerfile
More file actions
42 lines (30 loc) · 992 Bytes
/
prod.Dockerfile
File metadata and controls
42 lines (30 loc) · 992 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# Stage 1: Build stage with Poetry
FROM python:3.12-slim-bookworm AS builder
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
POETRY_HOME="/opt/poetry" \
PATH="$POETRY_HOME/bin:$PATH"
# Install Poetry
RUN python -m pip install poetry --no-cache-dir && \
poetry config virtualenvs.in-project true
WORKDIR /app
# Copy dependency files
COPY pyproject.toml poetry.lock ./
# Install dependencies
RUN poetry install --without dev --no-root
# Copy the rest of the application files
COPY . .
RUN rm -f pyproject.toml poetry.lock
# Stage 2: Production stage
FROM python:3.12-slim-bookworm
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PATH="/app/.venv/bin:$PATH" \
APP_STAGE="production"
WORKDIR /app
# Copy application files and virtual environment from the builder stage
COPY --from=builder /app /app
# Entrypoint for running the application
ENTRYPOINT ["sh", "./docker/docker-entrypoint.sh"]