From 6a3b6b20f0630f25aeaff91e913414dc0e2280f9 Mon Sep 17 00:00:00 2001 From: David Lynch Date: Thu, 20 Aug 2026 15:19:13 +0100 Subject: [PATCH] feat(no-ticket): adding container image build to CI --- .editorconfig | 2 +- .github/workflows/image-build.yml | 25 +++++++++++++++ .github/workflows/release.yml | 24 -------------- Dockerfile | 52 +++++++++++++++---------------- compose.yaml | 5 +++ 5 files changed, 57 insertions(+), 51 deletions(-) create mode 100644 .github/workflows/image-build.yml create mode 100644 compose.yaml diff --git a/.editorconfig b/.editorconfig index 057c2340..3d7bdfdc 100644 --- a/.editorconfig +++ b/.editorconfig @@ -11,5 +11,5 @@ quote_type = double max_line_length = 88 trim_trailing_whitespace = true -[site.yaml] +[{*.yaml,*.yml,*.kyaml}] indent_size = 2 diff --git a/.github/workflows/image-build.yml b/.github/workflows/image-build.yml new file mode 100644 index 00000000..e8d41dba --- /dev/null +++ b/.github/workflows/image-build.yml @@ -0,0 +1,25 @@ +name: Container Image Build +on: + push: + branches: + - master + pull_request: + branches: + - "**" +permissions: + contents: read +jobs: + image-build: + name: Build container image + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 + with: + persist-credentials: false + - name: Build image + run: | + docker compose build \ + --build-arg CLOUDSMITH_CLI_VERSION="$(cat VERSION)" \ + --build-arg VCS_REF="${GITHUB_SHA}" + - name: Test image + run: docker compose run cli diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index da2ab99d..d43a4d86 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -452,24 +452,6 @@ jobs: with: persist-credentials: false - - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 - with: - pattern: cloudsmith-linux-*-musl - merge-multiple: true - path: binaries - - - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 - with: - pattern: cloudsmith-linux-x86_64-gnu - merge-multiple: true - path: binaries - - - name: Set up the built cloudsmith binary on the runner - uses: ./.github/actions/setup-cloudsmith-binary - with: - version: ${{ needs.validate.outputs.version }} - add-local-bin: "true" - - uses: docker/setup-qemu-action@06116385d9baf250c9f4dcb4858b16962ea869c3 # v4.1.0 - uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0 @@ -494,12 +476,6 @@ jobs: - name: Build once and push the same image to both registries run: | set -euo pipefail - AMD64="binaries/cloudsmith-${VERSION}-linux-x86_64-musl.tar.gz" - ARM64="binaries/cloudsmith-${VERSION}-linux-aarch64-musl.tar.gz" - test -f "${AMD64}" - test -f "${AMD64}.sha256" - test -f "${ARM64}" - test -f "${ARM64}.sha256" # Immutable Cloudsmith repo: push the tag only if absent (inspect runs # post-auth, so non-zero = not present). Docker Hub is mutable. diff --git a/Dockerfile b/Dockerfile index 0e0f70f3..fec9a942 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,44 +1,44 @@ ARG ALPINE_IMAGE=alpine:3.21@sha256:48b0309ca019d89d40f670aa1bc06e426dc0931948452e8491e3d65087abc07d -FROM ${ALPINE_IMAGE} AS unpack +FROM astral/uv:alpine AS build -ARG TARGETARCH -ARG CLOUDSMITH_CLI_VERSION +WORKDIR /root/cloudsmith-cli + +RUN apk add --no-cache binutils + +ADD bin bin +ADD cloudsmith_cli cloudsmith_cli +ADD packaging packaging +ADD pyproject.toml pyproject.toml +ADD uv.lock uv.lock +ADD VERSION VERSION -COPY binaries/ /tmp/binaries/ +ARG CLOUDSMITH_CLI_VERSION +ARG PYTHON_VERSION=3.14 -RUN set -eu; \ - case "${TARGETARCH}" in \ - amd64) CS_ARCH="x86_64" ;; \ - arm64) CS_ARCH="aarch64" ;; \ - *) echo "Unsupported architecture: ${TARGETARCH}" >&2; exit 1 ;; \ - esac; \ - ARCHIVE="cloudsmith-${CLOUDSMITH_CLI_VERSION}-linux-${CS_ARCH}-musl.tar.gz"; \ - cd /tmp/binaries; \ - sha256sum -c "${ARCHIVE}.sha256"; \ - mkdir -p /opt; \ - tar -xzf "${ARCHIVE}" -C /opt +RUN uv sync --locked --no-dev --no-editable --group binary --extra all --python "${PYTHON_VERSION}" +RUN uv run --no-sync pyinstaller --clean --noconfirm packaging/pyinstaller/cloudsmith.spec FROM ${ALPINE_IMAGE} +COPY --from=build /root/cloudsmith-cli/dist/cloudsmith /opt/cloudsmith + ARG CLOUDSMITH_CLI_VERSION ARG VCS_REF LABEL maintainer="support@cloudsmith.io" \ - org.opencontainers.image.title="Cloudsmith CLI" \ - org.opencontainers.image.description="Official Cloudsmith CLI" \ - org.opencontainers.image.vendor="Cloudsmith" \ - org.opencontainers.image.url="https://cloudsmith.com" \ - org.opencontainers.image.source="https://github.com/cloudsmith-io/cloudsmith-cli" \ - org.opencontainers.image.documentation="https://docs.cloudsmith.com/developer-tools/cli" \ - org.opencontainers.image.licenses="Apache-2.0" \ - org.opencontainers.image.version="${CLOUDSMITH_CLI_VERSION}" \ - org.opencontainers.image.revision="${VCS_REF}" + org.opencontainers.image.title="Cloudsmith CLI" \ + org.opencontainers.image.description="Official Cloudsmith CLI" \ + org.opencontainers.image.vendor="Cloudsmith" \ + org.opencontainers.image.url="https://cloudsmith.com" \ + org.opencontainers.image.source="https://github.com/cloudsmith-io/cloudsmith-cli" \ + org.opencontainers.image.documentation="https://docs.cloudsmith.com/developer-tools/cli" \ + org.opencontainers.image.licenses="Apache-2.0" \ + org.opencontainers.image.version="${CLOUDSMITH_CLI_VERSION}" \ + org.opencontainers.image.revision="${VCS_REF}" ENV PATH="/opt/cloudsmith:${PATH}" -COPY --from=unpack /opt/cloudsmith /opt/cloudsmith - RUN adduser -D -u 1000 cloudsmith USER cloudsmith diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 00000000..01dfe5e5 --- /dev/null +++ b/compose.yaml @@ -0,0 +1,5 @@ +services: + cli: + image: cloudsmith-cli + build: + context: .