-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile-dev
68 lines (53 loc) · 1.84 KB
/
Dockerfile-dev
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
65
66
67
68
# https://github.com/python-poetry/poetry/discussions/1879#discussioncomment-216865
# `python-base` sets up all our shared environment variables
ARG PYTHON_VERSION=3.11
FROM python:${PYTHON_VERSION}-slim-bullseye as python-base
ENV PYTHONUNBUFFERED=1 \
PYTHONDEVMODE=1 \
PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
POETRY_VERSION=1.5.1 \
VENV_PATH="/opt/venv" \
POETRY_VIRTUALENVS_IN_PROJECT=true \
POETRY_NO_INTERACTION=1 \
CODE_PATH="/opt/code" \
TERM=xterm-256color
ENV XDG_CACHE_HOME="$CODE_PATH/.cache" \
XDG_CONFIG_HOME="/tmp/.config"
ENV PATH="$VENV_PATH/bin:$CODE_PATH/.venv/bin:$PATH"
ARG USER_ID=1000
ARG GROUP_ID=1000
ARG USER_NAME=app
RUN addgroup --gid $GROUP_ID --system $USER_NAME \
&& adduser --uid $USER_ID --system --no-create-home --shell=/bin/false --disabled-password --group $USER_NAME \
&& mkdir $CODE_PATH \
&& chown -R $USER_ID:$GROUP_ID $CODE_PATH
RUN apt-get update \
&& apt-get install --no-install-recommends -y \
make \
git \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# For pre-commit
RUN mkdir -p $XDG_CONFIG_HOME/git \
&& touch $XDG_CONFIG_HOME/git/config \
&& chown -R $USER_ID:$GROUP_ID $XDG_CONFIG_HOME \
&& git config --global safe.directory $CODE_PATH
FROM python-base as builder-base
RUN set -ex \
&& apt-get update \
&& apt-get install --no-install-recommends -y \
# deps for building python deps
build-essential \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN python -m venv $VENV_PATH
RUN pip install poetry==$POETRY_VERSION
# `development` image is used during development / testing
FROM python-base as development
ENV PYTHONDONTWRITEBYTECODE=1
WORKDIR $CODE_PATH
COPY --from=builder-base $VENV_PATH $VENV_PATH
USER $USER_NAME
CMD ["poetry", "install"]