-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
39 lines (31 loc) · 1012 Bytes
/
Dockerfile
File metadata and controls
39 lines (31 loc) · 1012 Bytes
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
ARG PY_VERSION=3.12
FROM python:${PY_VERSION}-slim AS base
# create non-root user (primarily for devcontainer)
RUN groupadd --gid 1000 vscode \
&& useradd --uid 1000 --gid 1000 -m vscode
WORKDIR /app
# install dependencies first for better layer caching
COPY pyproject.toml README.md LICENSE.txt ./
COPY src/ src/
RUN chown -R vscode:vscode /app
FROM base AS hatch
RUN pip3 install --no-cache-dir hatch
ENV HATCH_ENV=default
ENTRYPOINT ["hatch", "run"]
FROM base AS dev
COPY requirements/ requirements/
COPY requirements.txt ./
COPY tests/ tests/
COPY docs/ docs/
COPY mkdocs.yml ./
RUN pip3 install --no-cache-dir hatch \
&& hatch build \
&& pip3 install --no-cache-dir $(find /app -name 'requirement*.txt' -exec echo -n '-r {} ' \;)
USER vscode
FROM base AS prod
COPY --from=dev /app/dist/*.whl /tmp/
RUN pip3 install --no-cache-dir /tmp/*.whl \
&& rm -rf /tmp/*.whl
USER vscode
HEALTHCHECK --interval=30s --timeout=5s --retries=3 \
CMD python -c "import python_template" || exit 1