Skip to content

ci: build a multi-arch main image #11668

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

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
experiment
  • Loading branch information
matifali committed Jan 17, 2024
commit b6ee23bf4755e751a34c21ecbde5abd8ea960cda
12 changes: 8 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -710,8 +710,12 @@ jobs:
# replace + with - in tag
tag="${tag/+/-}"

# create an empty build directory
mkdir -p tmp
# create an empty build context directory
mkdir -p build-context
mkdir -p base-build-context

# copy the build artifacts to the build context
cp build/coder_*_linux_* build-context

# export version, base_tag, and tag as outputs
echo "version=$version" >> $GITHUB_OUTPUT
Expand All @@ -725,7 +729,7 @@ jobs:
uses: depot/build-push-action@v1
with:
project: 9rcqzb56rm
context: ./tmp
context: ./base-build-context
platforms: linux/amd64,linux/arm64,linux/arm/v7
tags: ${{ steps.build.outputs.base_tag }}
file: ./scripts/Dockerfile.base
Expand All @@ -736,7 +740,7 @@ jobs:
uses: depot/build-push-action@v1
with:
project: 9rcqzb56rm
context: ./tmp
context: ./build-context
platforms: linux/amd64,linux/arm64,linux/arm/v7
file: ./scripts/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
Expand Down
21 changes: 21 additions & 0 deletions scripts/Dockerfile.multi
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# This is the multi-arch Dockerfile used for Coder. Since it's multi-arch and
# cross-compiled, it cannot have ANY "RUN" commands. All binaries are built
# using the go toolchain on the host and then copied into the build context manullay.
ARG BASE_IMAGE
FROM $BASE_IMAGE

# LABEL doesn't add any real layers so it's fine (and easier) to do it here than
# in the build script.
ARG CODER_VERSION
LABEL \
org.opencontainers.image.title="Coder" \
org.opencontainers.image.description="A tool for provisioning self-hosted development environments with Terraform." \
org.opencontainers.image.url="https://github.com/coder/coder" \
org.opencontainers.image.source="https://github.com/coder/coder" \
org.opencontainers.image.version="$CODER_VERSION"


# The coder binary is available in the build context.
COPY --chown=1000:1000 --chmod=755 coder_*_linux_${TARGETARCH} /opt/coder

ENTRYPOINT [ "/opt/coder", "server" ]