Skip to content

feat: build and publish multiarch image#46

Merged
matifali merged 1 commit into
mainfrom
matifali/arm64
Jul 30, 2024
Merged

feat: build and publish multiarch image#46
matifali merged 1 commit into
mainfrom
matifali/arm64

Conversation

@matifali

@matifali matifali commented Jul 16, 2024

Copy link
Copy Markdown
Member

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 thread .github/workflows/ci.yaml
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

Comment thread 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 No newline at end of file

Copy link
Copy Markdown
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

@johnstcn johnstcn left a comment

Copy link
Copy Markdown
Member

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.

Comment thread scripts/Dockerfile

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Comment thread scripts/build.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build executable for ARM64

2 participants