Skip to content

Commit d5a1125

Browse files
committed
1 parent 1a4c98d commit d5a1125

File tree

1 file changed

+28
-18
lines changed

1 file changed

+28
-18
lines changed

Dockerfile

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,33 @@
1-
FROM flyingjoe/uvicorn-gunicorn-fastapi:python3.9-slim
2-
3-
WORKDIR /app
4-
5-
ENV PATH="${PATH}:/root/.local/bin"
6-
7-
ADD . /app/
8-
9-
EXPOSE 20000
10-
11-
RUN sed -i "s@http://deb.debian.org@http://mirrors.aliyun.com@g" /etc/apt/sources.list && rm -Rf /var/lib/apt/lists/* && apt-get update
12-
13-
RUN apt install curl -y
14-
15-
RUN curl -sSL https://install.python-poetry.org | python3 -
16-
17-
RUN /usr/local/bin/python -m pip install --no-cache-dir --upgrade --quiet pip
18-
1+
FROM sunpeek/poetry:py3.10-slim as base
2+
# python
3+
ENV PYTHONUNBUFFERED=1 \
4+
# prevents python creating .pyc files
5+
PYTHONDONTWRITEBYTECODE=1 \
6+
\
7+
POETRY_VERSION=1.1.4 \
8+
# make poetry install to this location
9+
POETRY_HOME="/opt/poetry" \
10+
POETRY_VIRTUALENVS_IN_PROJECT=true \
11+
POETRY_NO_INTERACTION=1 \
12+
\
13+
# paths
14+
# this is where our requirements + virtual environment will live
15+
PYSETUP_PATH="/opt/pysetup" \
16+
VENV_PATH="/opt/pysetup/.venv"
17+
18+
# prepend poetry and venv to path
19+
ENV PATH="$POETRY_HOME/bin:$VENV_PATH/bin:$PATH"
20+
21+
FROM base as base-builder
22+
WORKDIR $PYSETUP_PATH
23+
ADD ./poetry.lock ./pyproject.toml ./
1924
RUN poetry install
2025

26+
FROM base as pre-production
27+
EXPOSE 20000
28+
COPY --from=base-builder $VENV_PATH /app/.venv/
29+
COPY . /app/
2130
VOLUME /app/accounts /app/data
31+
WORKDIR /app
2232

2333
CMD poetry run python3 main.py

0 commit comments

Comments
 (0)