-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
39 lines (34 loc) · 1007 Bytes
/
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
39
##############
# BASE IMAGE #
##############
FROM python:3.10.5-slim as base
ENV PYTHONUNBUFFERED=1
ENV PATH=/opt/poetry/bin:$PATH
ENV POETRY_VIRTUALENVS_CREATE=0
ENV POETRY_HOME=/opt/poetry/
ADD https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py /tmp/get-poetry.py
RUN python /tmp/get-poetry.py
WORKDIR /app
COPY poetry.lock /app/poetry.lock
COPY pyproject.toml /app/pyproject.toml
RUN poetry install --no-dev --no-root
#####################
# DEVELOPMENT IMAGE #
#####################
FROM base as development
COPY . /app
RUN poetry install
CMD ["uvicorn", "--host", "0.0.0.0", "--port", "3000", "main:app", "--reload"]
####################
# PRODUCTION IMAGE #
####################
FROM base as production
# install project
COPY . /app
RUN poetry install --no-dev
ARG PUID=1000
ARG PGID=1000
RUN groupadd --gid ${PUID} app \
&& useradd --uid ${PGID} --gid app --shell /bin/bash --create-home app
USER app
CMD ["uvicorn", "--host", "0.0.0.0", "--port", "3000", "main:app"]