Skip to content
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

multi arch release images #631

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,7 @@ clean:
*-windows-amd64 \
*.sha256 \
$(NULL)

.PHONY: build_release_images
build_release_images:
bash ./hack/build_release_images.sh
19 changes: 9 additions & 10 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
FROM registry.access.redhat.com/ubi9/go-toolset:latest AS builder

WORKDIR /opt/app-root/src
COPY . .


#TODO Identify the full set of supported arch
#TODO Create a Make Target to build all supported release binaries
RUN go mod download
RUN go build -buildvcs=false -o ./releases/ocm ./cmd/ocm

ENV GOFLAGS=-buildvcs=false
RUN git config --global --add safe.directory /opt/app-root/src && \
make build_release_images

FROM registry.access.redhat.com/ubi9/ubi-micro:latest
LABEL name="ocm-cli"
LABEL description="OCM CLI"
LABEL io.k8s.description="OCM CLI"
LABEL com.redhat.component="ocm-cli"
LABEL distribution-scope="release"
LABEL name="ocm-cli" release="X.Y" url="https://github.com/openshift-online/ocm-cli"
LABEL vendor="Red Hat, Inc."
LABEL version="X.Y"

COPY LICENSE.txt /licenses
COPY --from=builder /opt/app-root/src/releases /releases
COPY --from=builder /opt/app-root/src/releases /releases
30 changes: 30 additions & 0 deletions hack/build_release_images.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
#This script invoked via a make target by the Dockerfile
#which builds a cli wrapper container that contains all release images

#Keeping it similar to ROSA official releases which only publish amd64 to mirror
#This list can be modified as needed if additional os or arch support is needed
archs=(amd64)
oses=(darwin windows linux)

REL_VER=$(git describe --tags --abbrev=0 | sed "s/v//")
mkdir -p releases

build_release() {
for os in ${oses[@]}
do
for arch in ${archs[@]}
do
if [[ $os == "windows" ]]; then
extension=".exe"
fi
GOOS=${os} GOARCH=${arch} go build -o /tmp/ocm_${os}_${arch} ./cmd/ocm
mv /tmp/ocm_${os}_${arch} ocm_v${REL_VER}${extension}
zip releases/ocm_${REL_VER}_${os}_${arch}.zip ocm_v${REL_VER}${extension}
rm ocm_v${REL_VER}${extension}
done
done
cd releases && sha256sum *zip > ocm_${REL_VER}_SHA256SUMS
}

build_release
Loading