From 09d46eb3a1dda33979273b5672d0a13972ee14e6 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Wed, 26 Mar 2025 10:40:07 -0400 Subject: [PATCH] new docker images --- .github/Dockerfile | 16 ------------ .github/workflows/cd.docker.yml | 25 ++++++++++++++----- .github/workflows/ci.docker.yml | 44 ++++++++++++++------------------- docker/Dockerfile.archlinux | 10 ++++++++ docker/Dockerfile.busybox | 19 ++++++++++++++ docker/Dockerfile.debian | 10 ++++++++ docker/Dockerfile.ubuntu | 10 ++++++++ 7 files changed, 87 insertions(+), 47 deletions(-) delete mode 100644 .github/Dockerfile create mode 100644 docker/Dockerfile.archlinux create mode 100644 docker/Dockerfile.busybox create mode 100644 docker/Dockerfile.debian create mode 100644 docker/Dockerfile.ubuntu diff --git a/.github/Dockerfile b/.github/Dockerfile deleted file mode 100644 index 393e6ab9d..000000000 --- a/.github/Dockerfile +++ /dev/null @@ -1,16 +0,0 @@ -FROM debian:buster-slim AS stage0 -COPY ./products/* /pkgx/ -RUN install -m 755 /pkgx/$(uname -m) /usr/local/bin/pkgx -RUN install -m 755 /pkgx/pkgm /usr/local/bin/pkgm -RUN echo 'export PS1="\\[\\033[38;5;63m\\]pkgx\\[\\033[0m\\]\\w $ "' >> /root/.bashrc - -FROM debian:buster-slim AS stage1 -RUN apt-get update && apt --yes install libc-dev libstdc++-8-dev libgcc-8-dev netbase libudev-dev ca-certificates -COPY --from=stage0 /usr/local/bin/pkgx /usr/local/bin/pkgx -COPY --from=stage0 /usr/local/bin/pkgm /usr/local/bin/pkgm -COPY --from=stage0 /root/.bashrc /root/.bashrc -ENV BASH_ENV=/root/.bashrc -ENV CLICOLOR_FORCE=1 -SHELL ["/bin/bash", "-c"] -CMD ["/bin/bash", "-i"] -ENTRYPOINT ["/usr/local/bin/pkgx"] diff --git a/.github/workflows/cd.docker.yml b/.github/workflows/cd.docker.yml index cfbdb4285..065ca7717 100644 --- a/.github/workflows/cd.docker.yml +++ b/.github/workflows/cd.docker.yml @@ -19,10 +19,17 @@ permissions: jobs: build-and-push-image: + strategy: + matrix: + variety: + - archlinux + - busybox + - debian + - ubuntu name: docker buildx pkgxdev/pkgx:${{ github.event.release.tag_name || github.event.inputs.tag }} runs-on: ubuntu-latest steps: - - uses: robinraju/release-downloader@v1.11 + - uses: robinraju/release-downloader@v1.12 with: releaseId: ${{ github.event.release.id }} tag: ${{ github.event.inputs.tag }} @@ -31,6 +38,10 @@ jobs: - name: is_latest? id: latest run: | + if [ ${{ matrix.variety }} != debian ]; then + echo "value=false" >> "${GITHUB_OUTPUT}" + return + fi TAG_NAME="${{ github.event.release.tag_name || github.event.inputs.tag }}" LATEST_RELEASE=$(gh api repos/${{ github.repository }}/releases/latest --jq '.tag_name') if [ "$TAG_NAME" == "$LATEST_RELEASE" ]; then @@ -74,10 +85,11 @@ jobs: flavor: | latest=${{ steps.latest.outputs.value }} tags: | - type=sha - type=semver,pattern=v{{version}},value=${{ github.event.release.tag_name || github.event.inputs.tag }} - type=semver,pattern=v{{major}}.{{minor}},value=${{ github.event.release.tag_name || github.event.inputs.tag }} - type=semver,pattern=v{{major}},value=${{ github.event.release.tag_name || github.event.inputs.tag }} + type=semver,pattern=v{{version}},value=${{ github.event.release.tag_name || github.event.inputs.tag }},enable=${{ matrix.variety == 'debian' }} + type=semver,pattern=v{{major}}.{{minor}},value=${{ github.event.release.tag_name || github.event.inputs.tag }},enable=${{ matrix.variety == 'debian' }} + type=semver,pattern=v{{major}},value=${{ github.event.release.tag_name || github.event.inputs.tag }},enable=${{ matrix.variety == 'debian' }} + type=raw,value=${{ matrix.variety }} + if: ${{ matrix.variety == 'debian' }} - uses: docker/setup-qemu-action@v3 - uses: docker/setup-buildx-action@v3 @@ -90,6 +102,7 @@ jobs: docker buildx build \ --push \ $tags \ + --tag pkgxdev/pkgx:${{matrix.variety}} \ --platform linux/amd64,linux/arm64 \ - --file ./src/.github/Dockerfile \ + --file ./src/.github/Dockerfile.${{ matrix.variety }} \ . diff --git a/.github/workflows/ci.docker.yml b/.github/workflows/ci.docker.yml index bdabe05e2..4c5d820b0 100644 --- a/.github/workflows/ci.docker.yml +++ b/.github/workflows/ci.docker.yml @@ -3,7 +3,7 @@ name: ci·docker on: pull_request: paths: - - .github/Dockerfile + - docker/Dockerfile.* - .github/workflows/ci.docker.yml concurrency: @@ -15,51 +15,45 @@ permissions: packages: write jobs: - docker-build: + go: runs-on: ubuntu-latest - container: debian:buster-slim + strategy: + matrix: + variety: + - archlinux + - busybox + - debian + - ubuntu steps: - uses: actions/checkout@v4 - - run: apt-get update && apt-get install -y curl gcc perl make - - - uses: dtolnay/rust-toolchain@stable - - run: cargo build --release - - - uses: actions/upload-artifact@v4 - with: - name: products - path: ./target/release/pkgx - - docker-test: - runs-on: ubuntu-latest - needs: docker-build - steps: - - uses: actions/checkout@v4 - - - uses: actions/download-artifact@v4 + - uses: robinraju/release-downloader@v1.12 with: - name: products + fileName: pkgx-*+linux+x86-64.tar.gz + latest: true - run: | mkdir products - mv ./pkgx products/$(uname -m) + tar xzf pkgx*.tar.gz + mv pkgx products/$(uname -m) curl https://pkgxdev.github.io/pkgm/pkgm.ts -o products/pkgm - run: docker build - --tag pkgxdev/pkgx - --file .github/Dockerfile + --tag pkgxdev/${{ matrix.variety }} + --file docker/Dockerfile.${{ matrix.variety }} . - run: | cat < Dockerfile - FROM pkgxdev/pkgx + FROM pkgxdev/${{ matrix.variety }} RUN pkgx --version RUN if git --version; then exit 1; fi RUN pkgx git --version + RUN pkgm --version RUN pkgm install git RUN if ! git --version; then exit 2; fi + RUN pkgx node --eval "console.log(1)" EoD docker build --file Dockerfile . diff --git a/docker/Dockerfile.archlinux b/docker/Dockerfile.archlinux new file mode 100644 index 000000000..5f60617df --- /dev/null +++ b/docker/Dockerfile.archlinux @@ -0,0 +1,10 @@ +FROM archlinux AS stage0 +COPY ./products/* /pkgx/ +RUN install -m 755 /pkgx/$(uname -m) /usr/local/bin/pkgx +RUN install -m 755 /pkgx/pkgm /usr/local/bin/pkgm + +FROM archlinux AS stage1 +COPY --from=stage0 /usr/local/bin/pkgx /usr/local/bin/pkgm /usr/local/bin/ + +CMD ["/bin/bash"] +ENTRYPOINT ["/usr/local/bin/pkgx"] diff --git a/docker/Dockerfile.busybox b/docker/Dockerfile.busybox new file mode 100644 index 000000000..cbb0dfaba --- /dev/null +++ b/docker/Dockerfile.busybox @@ -0,0 +1,19 @@ +FROM debian:buster-slim AS stage0 +COPY ./products/* /pkgx/ +RUN install -m 755 /pkgx/$(uname -m) /usr/local/bin/pkgx +RUN install -m 755 /pkgx/pkgm /usr/local/bin/pkgm + +# FIXME a newer glibc would be nice, but the libpthread.so we copy in then fails +FROM busybox:1.31-glibc AS stage1 +COPY --from=stage0 /usr/local/bin/pkgx /usr/local/bin/pkgm /usr/local/bin/ + +# pkgx packages also need libgcc +COPY --from=stage0 /lib/x86_64-linux-gnu/libgcc_s.so.1 /lib/libgcc_s.so.1 +# these are part of glibc but for some reason this image doesn’t have them +COPY --from=stage0 /lib/x86_64-linux-gnu/librt-2.28.so /lib/librt.so.1 +COPY --from=stage0 /lib/x86_64-linux-gnu/libdl-2.28.so /lib/libdl.so.2 +# we need env for `pkgm` +COPY --from=stage0 /usr/bin/env /usr/bin/env + +CMD ["/bin/bash"] +ENTRYPOINT ["/usr/local/bin/pkgx"] diff --git a/docker/Dockerfile.debian b/docker/Dockerfile.debian new file mode 100644 index 000000000..e17714cc0 --- /dev/null +++ b/docker/Dockerfile.debian @@ -0,0 +1,10 @@ +FROM debian:stable-slim AS stage0 +COPY ./products/* /pkgx/ +RUN install -m 755 /pkgx/$(uname -m) /usr/local/bin/pkgx +RUN install -m 755 /pkgx/pkgm /usr/local/bin/pkgm + +FROM debian:stable-slim AS stage1 +COPY --from=stage0 /usr/local/bin/pkgx /usr/local/bin/pkgm /usr/local/bin/ + +CMD ["/bin/bash"] +ENTRYPOINT ["/usr/local/bin/pkgx"] diff --git a/docker/Dockerfile.ubuntu b/docker/Dockerfile.ubuntu new file mode 100644 index 000000000..51dbeb52c --- /dev/null +++ b/docker/Dockerfile.ubuntu @@ -0,0 +1,10 @@ +FROM ubuntu AS stage0 +COPY ./products/* /pkgx/ +RUN install -m 755 /pkgx/$(uname -m) /usr/local/bin/pkgx +RUN install -m 755 /pkgx/pkgm /usr/local/bin/pkgm + +FROM ubuntu AS stage1 +COPY --from=stage0 /usr/local/bin/pkgx /usr/local/bin/pkgm /usr/local/bin/ + +CMD ["/bin/bash"] +ENTRYPOINT ["/usr/local/bin/pkgx"]