-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dockerfile
38 lines (30 loc) · 1.27 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
31
32
33
34
35
36
37
38
# Base Source https://fastapi.tiangolo.com/deployment/docker
# This is the first stage, to create the requirements.txt
FROM python:3.9 as requirements-stage
WORKDIR /tmp
RUN apt-get update && apt-get install -y \
build-essential \
libssl-dev \
libffi-dev \
python3-dev \
cargo \
&& rm -rf /var/lib/apt/lists/*
RUN /usr/local/bin/python -m pip install --upgrade pip && curl -sSL https://install.python-poetry.org | python3 -
COPY ["./pyproject.toml", "./poetry.lock", "/tmp/"]
RUN $HOME/.local/bin/poetry export -f requirements.txt --output requirements.txt --without-hashes
# Start final stage
FROM python:3.9
# Install Dependencies
COPY --from=requirements-stage /tmp/requirements.txt /tmp/requirements.txt
RUN /usr/local/bin/python -m pip install --upgrade pip && \
pip install --no-cache-dir --upgrade -r /tmp/requirements.txt
# Expose port 80
EXPOSE 80
# Copy the app
RUN ["mkdir", "-p", "/essensfindung/"]
COPY ./app /essensfindung/app
WORKDIR /essensfindung/app
# Setup local DB if needed
VOLUME [ "/essensfindung/app/data" ]
# Start gunicorn server with 2 workers, uvicorn worker type and use the 0.0.0.0 host with port 80
ENTRYPOINT ["gunicorn", "-w", "2", "-k", "uvicorn.workers.UvicornWorker", "-b", "0.0.0.0:80", "--preload", "main:app", "main:app"]