Skip to content

Commit 75d85b5

Browse files
authored
feat: set up dockerfile (#87)
Fixes #8
1 parent 16545d7 commit 75d85b5

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**/__pycache__

.github/workflows/test.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,23 @@ jobs:
9898
steps:
9999
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
100100
- uses: hynek/build-and-inspect-python-package@b4fc3f6ba2b3da04f09659be99e2a29fb6146a61 # v2.6.0
101+
102+
docker:
103+
name: Build and run the docker image
104+
runs-on: ubuntu-24.04
105+
env:
106+
NO_COLOR: 1
107+
steps:
108+
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
109+
- run: pipx install hatch
110+
- name: Get package version
111+
id: package-version
112+
run: echo "version=$(hatch version)" >> $GITHUB_OUTPUT
113+
- uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0
114+
- name: Build and push
115+
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0
116+
with:
117+
load: true
118+
tags: afuetterer/python-re3data:test
119+
build-args: VERSION=${{ steps.package-version.outputs.version }}
120+
- run: docker run --rm afuetterer/python-re3data:test --help

Dockerfile

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# syntax=docker/dockerfile:1
2+
3+
# base
4+
# ----------------------------
5+
FROM python:3.12-slim as base
6+
7+
ENV PYTHONDONTWRITEBYTECODE=1 \
8+
PYTHONUNBUFFERED=1 \
9+
PIP_DISABLE_PIP_VERSION_CHECK=1 \
10+
PIP_NO_CACHE_DIR=1 \
11+
PIP_ROOT_USER_ACTION=ignore
12+
13+
# build stage
14+
# ----------------------------
15+
FROM base as build
16+
17+
WORKDIR /app
18+
19+
RUN python -m pip install build
20+
21+
COPY pyproject.toml .
22+
COPY README.md .
23+
COPY src ./src
24+
25+
RUN python -m build --wheel
26+
27+
# runtime stage
28+
# ----------------------------
29+
FROM base as runtime
30+
31+
ARG VERSION
32+
33+
RUN adduser --group --system --no-create-home re3data
34+
35+
WORKDIR /app
36+
37+
COPY --from=build /app/dist ./dist
38+
39+
RUN python -m pip install "./dist/python_re3data-$VERSION-py3-none-any.whl[cli]"
40+
41+
USER re3data
42+
43+
ENTRYPOINT ["re3data"]

0 commit comments

Comments
 (0)