-
Notifications
You must be signed in to change notification settings - Fork 7
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
Conversation
- 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! |
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.
setup-go has a built-in cache that works as expected.
- 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 |
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.
setup-go has a built-in cache that works as expected.
- 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 |
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.
moved pushing and building to the ./scripts/build.sh
scripts/build.sh
Outdated
# 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 |
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.
--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.
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.
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 |
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.
reviewer note: this comes from --platform
ref: https://docs.docker.com/build/guide/multi-platform/#platform-build-arguments
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