-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
30 lines (23 loc) · 1.01 KB
/
Dockerfile
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
# Build arguments
ARG PYTHON_VERSION=3.10-slim
FROM python:${PYTHON_VERSION}
# https://docs.python.org/3/using/cmdline.html#envvar-PYTHONDONTWRITEBYTECODE
# Prevents Python from writing .pyc files to disc
ENV PYTHONDONTWRITEBYTECODE 1
# ensures that the python output is sent straight to terminal (e.g. your container log)
# without being first buffered and that you can see the output of your application (e.g. django logs)
# in real time. Equivalent to python -u: https://docs.python.org/3/using/cmdline.html#cmdoption-u
ENV PYTHONUNBUFFERED 1
# Install virtualenv and create a virtual environment
RUN pip install --no-cache-dir -U poetry && \
poetry config virtualenvs.create false
# Copy the poetry.lock and pyproject.toml files
# and install dependencies
WORKDIR /tmp
COPY poetry.lock pyproject.toml ./
RUN poetry install --no-dev --no-interaction --no-ansi
# Copy the project files into the working directory
WORKDIR /app
COPY . .
# Run the application
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "80"]