-
Notifications
You must be signed in to change notification settings - Fork 42
feat(no-ticket): adding container image build to CI #369
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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}" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. previously we had no python or uv dependency due to just dropping in the standalone binary that takes care of all those concerns.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The final image in this build only contains the standalone binary. It is ideal to build container images from source, since it means builds are more declarative (docker isn't a declarative build format since it calls out to the internet, but its better than copying from local directories.) |
||
| 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 | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| services: | ||
| cli: | ||
| image: cloudsmith-cli | ||
| build: | ||
| context: . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we still maintain the multi-architecture images by changing this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can add a matrix to build it for
amd64andaarch64if needed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
more the merrier 😛 our release workflow pushes the docker image to cloudsmith and dockerhub