-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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" | ||
|
||
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 | ||
# TODO PRE_COMMIT_HOME | ||
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
|
||
x-common: &common | ||
build: | ||
target: development | ||
context: . | ||
dockerfile: Dockerfile-dev | ||
args: | ||
- PYTHON_VERSION=${PYTHON_VERSION:-3.11} | ||
image: "picodi:dev" | ||
volumes: | ||
- .:/opt/code | ||
|
||
services: | ||
devtools: | ||
<<: *common | ||
command: sleep infinity | ||
|
||
app: | ||
<<: *common | ||
restart: "no" | ||
ports: | ||
- "8000:8000" |