-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.flask
36 lines (26 loc) · 965 Bytes
/
Dockerfile.flask
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
# Use the official Python image as a parent image
FROM python:3.11-slim as builder
# Set environment variables
ENV POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_IN_PROJECT=1 \
POETRY_VIRTUALENVS_CREATE=1 \
POETRY_CACHE_DIR=/tmp/poetry_cache
# Install Poetry
RUN pip install poetry
# Set the working directory inside the container
WORKDIR /app
# Copy your local Poetry files into the container
COPY pyproject.toml poetry.lock ./
# Install the application
RUN poetry install --without dev --no-root && rm -rf $POETRY_CACHE_DIR
# The runtime image, used to just run the code provided its virtual environment
FROM python:3.11-slim as runtime
# Set environment variables
ENV VIRTUAL_ENV=/app/.venv \
PATH="/app/.venv/bin:$PATH"
# Copy the venv folder to the new image
COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
EXPOSE 8000
# Copy the code to the new image
COPY src/app.py /app/
COPY src/tasks/celeryconf.py src/tasks/tasks.py /app/tasks/