39 lines
1.2 KiB
Docker
39 lines
1.2 KiB
Docker
### STAGE 1 - Builder image ###
|
|
# Builder container
|
|
FROM python:3.12 AS builder
|
|
# Install Poetry
|
|
RUN curl -sSL https://install.python-poetry.org | python3 -
|
|
ENV PATH="${PATH}:/root/.local/bin"
|
|
# Create build directory
|
|
WORKDIR /build
|
|
# Copy project files
|
|
COPY . ./
|
|
# Run poetry update to download dependencies
|
|
RUN poetry update --no-interaction --no-ansi
|
|
# Build project
|
|
RUN poetry build
|
|
|
|
### STAGE 2 — Final image ###
|
|
FROM python:3.12-slim AS deploy
|
|
# Create app run directory
|
|
WORKDIR /app
|
|
# Copy application custom static files
|
|
RUN mkdir -p static
|
|
COPY ./static/cantorair.jpg ./static
|
|
COPY ./static/cantorair_blue.jpg ./static
|
|
# Copy application custom templates for admin page
|
|
RUN mkdir -p /templates/admin
|
|
COPY ./templates/admin/* ./templates/admin/
|
|
# Copy and install application wheel package
|
|
COPY --from=builder /build/dist/*.whl ./
|
|
RUN pip install --no-cache-dir *.whl
|
|
RUN pip install gunicorn whitenoise
|
|
# Copy entryupoint bash script
|
|
COPY ./docker/entrypoint.sh ./
|
|
# Collect build number from build arg
|
|
ARG GIT_HASH
|
|
ENV VERSION=${GIT_HASH}
|
|
ENTRYPOINT ["/app/entrypoint.sh"]
|
|
# Command to be executed after entry point
|
|
CMD ["gunicorn", "cntmanage.wsgi:application", "--bind", "0.0.0.0:8000", "--timeout", "600"]
|