generated from br3ndonland/template-python
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Dockerfile
79 lines (76 loc) · 2.33 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# syntax=docker/dockerfile:1
ARG PYTHON_VERSION=3.12 LINUX_VERSION=
FROM python:${PYTHON_VERSION}${LINUX_VERSION:+-$LINUX_VERSION} AS builder
LABEL org.opencontainers.image.authors="Brendon Smith <[email protected]>"
LABEL org.opencontainers.image.description="Docker images and utilities to power your Python APIs and help you ship faster."
LABEL org.opencontainers.image.licenses="MIT"
LABEL org.opencontainers.image.source="https://github.com/br3ndonland/inboard"
LABEL org.opencontainers.image.title="inboard"
LABEL org.opencontainers.image.url="https://github.com/br3ndonland/inboard/pkgs/container/inboard"
ARG \
HATCH_VERSION=1.13.0 \
LINUX_VERSION \
PIPX_VERSION=1.7.1
ENV \
HATCH_ENV_TYPE_VIRTUAL_PATH=.venv \
HATCH_VERSION=$HATCH_VERSION \
LINUX_VERSION=$LINUX_VERSION \
PATH=/opt/pipx/bin:/app/.venv/bin:$PATH \
PIPX_BIN_DIR=/opt/pipx/bin \
PIPX_HOME=/opt/pipx/home \
PIPX_VERSION=$PIPX_VERSION \
PYTHONPATH=/app
COPY --link pyproject.toml README.md /app/
WORKDIR /app
RUN <<HEREDOC
. /etc/os-release
if [ "$ID" = "alpine" ]; then
apk add --no-cache --virtual .build-deps \
gcc libc-dev libffi-dev make openssl-dev
elif [ "${LINUX_VERSION%%-*}" = "slim" ]; then
apt-get update -qy
apt-get install -qy --no-install-recommends \
gcc libc-dev make wget
fi
python -m pip install --no-cache-dir --upgrade pip "pipx==$PIPX_VERSION"
pipx install "hatch==$HATCH_VERSION"
HEREDOC
COPY --link inboard /app/inboard
ENTRYPOINT ["python"]
CMD ["-m", "inboard.start"]
FROM builder AS base
ENV APP_MODULE=inboard.app.main_base:app
RUN <<HEREDOC
hatch env create base
. /etc/os-release
if [ "$ID" = "alpine" ]; then
apk del .build-deps
elif [ "${LINUX_VERSION%%-*}" = "slim" ]; then
apt-get purge --auto-remove -qy \
gcc libc-dev make wget
fi
HEREDOC
FROM builder AS fastapi
ENV APP_MODULE=inboard.app.main_fastapi:app
RUN <<HEREDOC
hatch env create fastapi
. /etc/os-release
if [ "$ID" = "alpine" ]; then
apk del .build-deps
elif [ "${LINUX_VERSION%%-*}" = "slim" ]; then
apt-get purge --auto-remove -qy \
gcc libc-dev make wget
fi
HEREDOC
FROM builder AS starlette
ENV APP_MODULE=inboard.app.main_starlette:app
RUN <<HEREDOC
hatch env create starlette
. /etc/os-release
if [ "$ID" = "alpine" ]; then
apk del .build-deps
elif [ "${LINUX_VERSION%%-*}" = "slim" ]; then
apt-get purge --auto-remove -qy \
gcc libc-dev make wget
fi
HEREDOC