Skip to content

Commit 4adae45

Browse files
committed
chore(ci): build and publish docker image
1 parent 0e382da commit 4adae45

File tree

3 files changed

+71
-33
lines changed

3 files changed

+71
-33
lines changed

.dockerignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
__pycache__/
2+
.venv
3+
.git
4+
output
5+
build
6+
.ruff_cache
7+
.pytest_cache
8+
.mypy_cache

.github/workflows/cicd.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,53 @@ jobs:
144144
uses: pypa/gh-action-pypi-publish@release/v1
145145
with:
146146
password: ${{ secrets.PYPI_API_TOKEN }}
147+
148+
publish_image:
149+
runs-on: ubuntu-latest
150+
needs: [test_and_build]
151+
if: github.event.repository.fork == false && startsWith(github.ref, 'refs/tags')
152+
steps:
153+
- name: Checkout
154+
uses: actions/checkout@v3
155+
156+
- name: Download build artifact
157+
uses: actions/download-artifact@v3
158+
with:
159+
name: wheel2deb_linux_amd64
160+
161+
- name: Set execute permission
162+
run: chmod +x wheel2deb_linux_amd64
163+
164+
- name: Login to GitHub Container Registry
165+
uses: docker/login-action@v3
166+
with:
167+
registry: ghcr.io
168+
username: ${{ github.actor }}
169+
password: ${{ secrets.GITHUB_TOKEN }}
170+
171+
- name: Set docker image tags and labels
172+
id: meta
173+
uses: docker/metadata-action@v5
174+
with:
175+
images: ghcr.io/upciti/wheel2deb
176+
tags: |
177+
type=semver,pattern={{version}}
178+
type=semver,pattern={{major}}.{{minor}}
179+
type=semver,pattern={{major}}
180+
type=ref,event=branch
181+
182+
- name: Build Docker image
183+
uses: docker/build-push-action@v6
184+
with:
185+
context: .
186+
build-args: |
187+
WHEEL2DEB_PATH=wheel2deb_linux_amd64
188+
tags: ${{ steps.meta.outputs.tags }}
189+
labels: ${{ steps.meta.outputs.labels }}
190+
191+
- name: Check Docker image
192+
run: docker run --rm -i ghcr.io/${{ github.event.repository.full_name }}:latest --help
193+
194+
- name: Publish Docker image
195+
run: |
196+
docker push --all-tags ghcr.io/${{ github.event.repository.full_name }}

Dockerfile

Lines changed: 13 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,20 @@
1-
FROM python:3.8-buster AS builder
2-
RUN apt-get -yq update \
3-
&& apt-get -yq --no-install-suggests --no-install-recommends install \
4-
git \
5-
&& apt-get clean
6-
COPY . /src
7-
RUN cd src && python3 setup.py bdist_wheel
8-
1+
FROM wakemeops/debian:bookworm
92

10-
FROM debian:buster AS base
3+
ARG WHEEL2DEB_PATH="dist/wheel2deb"
4+
COPY ${WHEEL2DEB_PATH} /usr/local/bin/wheel2deb
115

12-
RUN dpkg --add-architecture armhf \
13-
&& apt-get -yq update \
14-
&& apt-get -yq --no-install-suggests --no-install-recommends install \
15-
libc6:armhf \
16-
binutils-arm-linux-gnueabihf \
6+
RUN install_packages \
177
build-essential \
18-
debhelper \
19-
devscripts \
208
fakeroot \
21-
lintian \
22-
apt-file \
23-
python3-distutils \
24-
python3-apt \
25-
curl \
26-
&& apt-get clean
27-
28-
RUN curl -nSL https://bootstrap.pypa.io/get-pip.py > /tmp/get-pip.py \
29-
&& chmod +x /tmp/get-pip.py \
30-
&& python3 /tmp/get-pip.py \
31-
&& rm /tmp/get-pip.py
32-
33-
RUN pip3 install --no-cache-dir pytest pytest-cov
9+
debhelper \
10+
binutils-arm-linux-gnueabihf \
11+
binutils-aarch64-linux-gnu \
12+
git \
13+
ca-certificates \
14+
apt-file
3415

35-
COPY --from=builder /src/dist/*.whl /
36-
RUN pip3 install --no-cache-dir /*.whl && rm /*.whl
16+
RUN dpkg --add-architecture armhf && \
17+
dpkg --add-architecture arm64
3718

38-
VOLUME /data
39-
WORKDIR /data
4019
ENTRYPOINT ["wheel2deb"]
20+
USER 1000

0 commit comments

Comments
 (0)