Skip to content

feat: build and publish multiarch image #46

New issue

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

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

Already on GitHub? # to your account

Merged
merged 1 commit into from
Jul 30, 2024
Merged

feat: build and publish multiarch image #46

merged 1 commit into from
Jul 30, 2024

Conversation

matifali
Copy link
Member

@matifali matifali commented Jul 16, 2024

This pull request updates the release workflow to build and push a multi-arch image and simplifies the CI process. The changes include:

Supersedes #44
Closes #29

@matifali matifali self-assigned this Jul 16, 2024
Comment on lines -33 to -45
- name: Echo Go Cache Paths
id: go-cache-paths
run: |
echo "GOCACHE=$(go env GOCACHE)" >> ${{ runner.os == 'Windows' && '$env:' || '$' }}GITHUB_OUTPUT
echo "GOMODCACHE=$(go env GOMODCACHE)" >> ${{ runner.os == 'Windows' && '$env:' || '$' }}GITHUB_OUTPUT

- name: Go Build Cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.GOCACHE }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.**', '**.go') }}

# Install Go!
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setup-go has a built-in cache that works as expected.

Comment on lines -24 to -36
- name: Echo Go Cache Paths
id: go-cache-paths
run: |
echo "GOCACHE=$(go env GOCACHE)" >> ${{ runner.os == 'Windows' && '$env:' || '$' }}GITHUB_OUTPUT
echo "GOMODCACHE=$(go env GOMODCACHE)" >> ${{ runner.os == 'Windows' && '$env:' || '$' }}GITHUB_OUTPUT

- name: Go Build Cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.GOCACHE }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.**', '**.go') }}

- uses: actions/setup-go@v5
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setup-go has a built-in cache that works as expected.

Comment on lines -54 to -62
- name: Push Image
run: |
VERSION=$(./scripts/version.sh)
BASE=ghcr.io/coder/coder-logstream-kube
IMAGE=$BASE:$VERSION
docker tag coder-logstream-kube:latest $IMAGE
docker tag coder-logstream-kube:latest $BASE:latest
docker push $IMAGE
docker push $BASE:latest
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved pushing and building to the ./scripts/build.sh

scripts/build.sh Outdated
Comment on lines 37 to 45
# Build
if [ "$CI" = "false" ]; then
docker buildx build --platform linux/$current -t coder-logstream-kube --load .
else
VERSION=$(../scripts/version.sh)
BASE=ghcr.io/coder/coder-logstream-kube
IMAGE=$BASE:$VERSION
docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t $IMAGE -t $BASE:latest --push.
fi
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--load only works for single arch images, so it can not be used with a multi arch manifest. As a workaround, I split the local and CI build commands.

Locally, we only build for the current arch; in CI, we create a multi-arch image.

@matifali matifali changed the title Add multiarch image and simplify CI feat: build and publish multiarch image Jul 16, 2024
@matifali matifali requested review from johnstcn and removed request for coadler and deansheather July 26, 2024 09:49
Copy link
Member

@johnstcn johnstcn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could do with a run of shellcheck on build.sh but I don't need to review again.


ENTRYPOINT ["/coder-logstream-kube"]
FROM --platform=$BUILDPLATFORM scratch AS base
ARG TARGETARCH
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matifali matifali merged commit 89b4709 into main Jul 30, 2024
1 check passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Build executable for ARM64
2 participants