-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
64 lines (44 loc) · 1.49 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
FROM python:3.10.0-slim as build
RUN apt-get update \
&& apt-get install libffi-dev \
gcc python3-dev libpq-dev curl build-essential -y \
&& apt-get clean
ENV APP_HOME="/app"
WORKDIR $APP_HOME
# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV PIP_NO_CACHE_DIR=off
ENV PIP_DISABLE_PIP_VERSION_CHECK=on
ENV PIP_DEFAULT_TIMEOUT=100
# poetry
# https://python-poetry.org/docs/configuration/#using-environment-variables
ENV POETRY_VERSION=1.8.3
# make poetry install to this location
ENV POETRY_HOME="/opt/poetry"
ENV POETRY_VIRTUALENVS_PATH=".venv"
ENV POETRY_VIRTUALENVS_IN_PROJECT=true
ENV POETRY_NO_INTERACTION=1
ENV VENV_DIR=$APP_HOME/.venv/
# prepend poetry and venv to path
ENV PATH="$POETRY_HOME/bin:$APP_HOME/.venv/bin:$PATH"
# install poetry - respects $POETRY_VERSION & $POETRY_HOME
RUN curl -sSL https://install.python-poetry.org | python
COPY poetry.lock pyproject.toml ./
RUN poetry install
COPY . .
# ================================ Main Build ================================
FROM python:3.10.0-slim
RUN apt-get update && apt-get install -y netcat && apt-get clean
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV APP_HOME="/app"
WORKDIR $APP_HOME
ENV POETRY_HOME="/opt/poetry"
ENV VENV_DIR="${APP_HOME}/.venv"
COPY --from=build $APP_HOME $APP_HOME
COPY --from=build $POETRY_HOME $POETRY_HOME
ENV PATH="$POETRY_HOME/bin:$VENV_DIR/bin:$PATH"
RUN chmod +x ./k8s/scripts/api.sh
RUN chmod +x ./k8s/scripts/migrate-db.sh
CMD ["./k8s/scripts/api.sh"]