Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ci): build and publish docker image #68

Merged
merged 1 commit into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
__pycache__/
.venv
.git
output
build
.ruff_cache
.pytest_cache
.mypy_cache
50 changes: 50 additions & 0 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,53 @@ jobs:
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}

publish_image:
runs-on: ubuntu-latest
needs: [test_and_build]
if: github.event.repository.fork == false && startsWith(github.ref, 'refs/tags')
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Download build artifact
uses: actions/download-artifact@v3
with:
name: wheel2deb_linux_amd64

- name: Set execute permission
run: chmod +x wheel2deb_linux_amd64

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set docker image tags and labels
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/upciti/wheel2deb
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=ref,event=branch

- name: Build Docker image
uses: docker/build-push-action@v6
with:
context: .
build-args: |
WHEEL2DEB_PATH=wheel2deb_linux_amd64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Check Docker image
run: docker run --rm -i ghcr.io/${{ github.event.repository.full_name }}:latest --help

- name: Publish Docker image
run: |
docker push --all-tags ghcr.io/${{ github.event.repository.full_name }}
46 changes: 13 additions & 33 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,40 +1,20 @@
FROM python:3.8-buster AS builder
RUN apt-get -yq update \
&& apt-get -yq --no-install-suggests --no-install-recommends install \
git \
&& apt-get clean
COPY . /src
RUN cd src && python3 setup.py bdist_wheel

FROM wakemeops/debian:bookworm

FROM debian:buster AS base
ARG WHEEL2DEB_PATH="dist/wheel2deb"
COPY ${WHEEL2DEB_PATH} /usr/local/bin/wheel2deb

RUN dpkg --add-architecture armhf \
&& apt-get -yq update \
&& apt-get -yq --no-install-suggests --no-install-recommends install \
libc6:armhf \
binutils-arm-linux-gnueabihf \
RUN install_packages \
build-essential \
debhelper \
devscripts \
fakeroot \
lintian \
apt-file \
python3-distutils \
python3-apt \
curl \
&& apt-get clean

RUN curl -nSL https://bootstrap.pypa.io/get-pip.py > /tmp/get-pip.py \
&& chmod +x /tmp/get-pip.py \
&& python3 /tmp/get-pip.py \
&& rm /tmp/get-pip.py

RUN pip3 install --no-cache-dir pytest pytest-cov
debhelper \
binutils-arm-linux-gnueabihf \
binutils-aarch64-linux-gnu \
git \
ca-certificates \
apt-file

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

VOLUME /data
WORKDIR /data
ENTRYPOINT ["wheel2deb"]
USER 1000
Loading