From 1dbe4f22ac6160d825b90411897575482ced952c Mon Sep 17 00:00:00 2001 From: Alex Lovell-Troy Date: Mon, 1 Jun 2026 11:39:01 -0400 Subject: [PATCH 01/13] Fix multi-arch container builds by consolidating build jobs Replace separate amd64/arm64 jobs with single multi-platform build to produce proper manifest list. Prevents tag overwrites and enables automatic platform selection when pulling images. Signed-off-by: Alex Lovell-Troy --- .github/workflows/upstream-docker-release.yml | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/.github/workflows/upstream-docker-release.yml b/.github/workflows/upstream-docker-release.yml index cc798ce..3ff45cc 100644 --- a/.github/workflows/upstream-docker-release.yml +++ b/.github/workflows/upstream-docker-release.yml @@ -22,22 +22,15 @@ permissions: write-all # Necessary for the generate-build-provenance action with jobs: image: - name: Build Image + name: Build & Push Multi-arch Image uses: OpenCHAMI/github-actions/.github/workflows/docker-build-release.yml@v3.3 with: fetch-depth: 1 registry-name: ghcr.io/openchami/pcs cgo-enabled: 1 - platforms: "linux/amd64" + # Build both amd64 and arm64 in a single run – Docker Buildx will create a manifest list. + platforms: "linux/amd64,linux/arm64" docker-file: "Dockerfile.build" - image_arm: - name: Build ARM Image - uses: OpenCHAMI/github-actions/.github/workflows/docker-build-release.yml@v3.3 - with: - fetch-depth: 1 - registry-name: ghcr.io/openchami/pcs - cgo-enabled: 1 + # The arm64 build needs the cross-compiler; the amd64 build simply ignores it. additional-env-vars: | CC=aarch64-linux-gnu-gcc - platforms: "linux/arm64" - docker-file: "Dockerfile.build" From 47b945d8110e0bcda27afd2d4909ed2400747a6c Mon Sep 17 00:00:00 2001 From: Alex Lovell-Troy Date: Mon, 1 Jun 2026 12:04:54 -0400 Subject: [PATCH 02/13] Refactor build command in Dockerfile to handle architecture-specific compilation Signed-off-by: Alex Lovell-Troy --- Dockerfile.build | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/Dockerfile.build b/Dockerfile.build index b067aba..076318a 100644 --- a/Dockerfile.build +++ b/Dockerfile.build @@ -53,12 +53,21 @@ ARG CGO_ENABLED RUN mkdir bin # Use shell parameter expansion to add -ldflags if CC is set to specify the external linker -RUN CGO_ENABLED="${CGO_ENABLED}" \ - GOOS=linux \ - GOARCH="${TARGETARCH}" \ - CC="${CC}" \ - GO111MODULE=on \ - go build ${CC:+-ldflags="-extld=$CC"} -v -o bin/power-control ./cmd/power-control +# For arm64, use the cross-compiler; for amd64, use the default compiler +RUN if [ "${TARGETARCH}" = "arm64" ]; then \ + CGO_ENABLED="${CGO_ENABLED}" \ + GOOS=linux \ + GOARCH="${TARGETARCH}" \ + CC="${CC}" \ + GO111MODULE=on \ + go build -ldflags="-extld=${CC}" -v -o bin/power-control ./cmd/power-control; \ + else \ + CGO_ENABLED="${CGO_ENABLED}" \ + GOOS=linux \ + GOARCH="${TARGETARCH}" \ + GO111MODULE=on \ + go build -v -o bin/power-control ./cmd/power-control; \ + fi ### release image # TODO seems kinda off that we don't pin wolfi or tini, but whatever From 826f1c9bd5e92f783596824af217edcaaf047d92 Mon Sep 17 00:00:00 2001 From: Alex Lovell-Troy Date: Mon, 1 Jun 2026 12:12:53 -0400 Subject: [PATCH 03/13] Enhance Dockerfile for multi-arch builds by adding build-essential and refining cross-compilation settings Signed-off-by: Alex Lovell-Troy --- Dockerfile.build | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/Dockerfile.build b/Dockerfile.build index 076318a..950f9bb 100644 --- a/Dockerfile.build +++ b/Dockerfile.build @@ -20,8 +20,9 @@ RUN printf "Building for TARGETPLATFORM=${TARGETPLATFORM}" \ && printf "With 'uname -s': $(uname -s) and 'uname -m': $(uname -m)" # Install cross-compilation dependencies +# Install build-essential for native compilation and aarch64 cross-compiler for ARM builds RUN apt-get update && \ - apt-get install -y g++-aarch64-linux-gnu && \ + apt-get install -y build-essential g++-aarch64-linux-gnu && \ rm -rf /var/lib/apt/lists/* WORKDIR /workspace @@ -52,20 +53,17 @@ ARG CGO_ENABLED RUN mkdir bin -# Use shell parameter expansion to add -ldflags if CC is set to specify the external linker -# For arm64, use the cross-compiler; for amd64, use the default compiler -RUN if [ "${TARGETARCH}" = "arm64" ]; then \ - CGO_ENABLED="${CGO_ENABLED}" \ - GOOS=linux \ - GOARCH="${TARGETARCH}" \ - CC="${CC}" \ - GO111MODULE=on \ +# Build the binary with appropriate cross-compilation settings +# For arm64, use the cross-compiler; for amd64, use the default toolchain +RUN set -ex && \ + export CGO_ENABLED="${CGO_ENABLED}" && \ + export GOOS=linux && \ + export GOARCH="${TARGETARCH}" && \ + export GO111MODULE=on && \ + if [ "${TARGETARCH}" = "arm64" ]; then \ + export CC="${CC:-aarch64-linux-gnu-gcc}" && \ go build -ldflags="-extld=${CC}" -v -o bin/power-control ./cmd/power-control; \ else \ - CGO_ENABLED="${CGO_ENABLED}" \ - GOOS=linux \ - GOARCH="${TARGETARCH}" \ - GO111MODULE=on \ go build -v -o bin/power-control ./cmd/power-control; \ fi From 7b48cb63ee34033ff11af28387b061a55d515e2d Mon Sep 17 00:00:00 2001 From: Alex Lovell-Troy Date: Mon, 1 Jun 2026 12:55:16 -0400 Subject: [PATCH 04/13] Refactor Dockerfile.build to set CC based on target architecture for multi-arch builds Signed-off-by: Alex Lovell-Troy --- .github/workflows/upstream-docker-release.yml | 5 +---- Dockerfile.build | 9 +++++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/upstream-docker-release.yml b/.github/workflows/upstream-docker-release.yml index 3ff45cc..0b02938 100644 --- a/.github/workflows/upstream-docker-release.yml +++ b/.github/workflows/upstream-docker-release.yml @@ -28,9 +28,6 @@ jobs: fetch-depth: 1 registry-name: ghcr.io/openchami/pcs cgo-enabled: 1 - # Build both amd64 and arm64 in a single run – Docker Buildx will create a manifest list. platforms: "linux/amd64,linux/arm64" docker-file: "Dockerfile.build" - # The arm64 build needs the cross-compiler; the amd64 build simply ignores it. - additional-env-vars: | - CC=aarch64-linux-gnu-gcc + # Don't pass CC here - let the Dockerfile set it based on TARGETARCH diff --git a/Dockerfile.build b/Dockerfile.build index 950f9bb..c6022ff 100644 --- a/Dockerfile.build +++ b/Dockerfile.build @@ -54,16 +54,21 @@ ARG CGO_ENABLED RUN mkdir bin # Build the binary with appropriate cross-compilation settings -# For arm64, use the cross-compiler; for amd64, use the default toolchain +# Set CC based on target architecture (don't rely on build args for multi-arch builds) RUN set -ex && \ + echo "Building for TARGETARCH=${TARGETARCH}" && \ export CGO_ENABLED="${CGO_ENABLED}" && \ export GOOS=linux && \ export GOARCH="${TARGETARCH}" && \ export GO111MODULE=on && \ if [ "${TARGETARCH}" = "arm64" ]; then \ - export CC="${CC:-aarch64-linux-gnu-gcc}" && \ + echo "Using ARM64 cross-compiler" && \ + export CC="aarch64-linux-gnu-gcc" && \ + echo "CC is now: ${CC}" && \ go build -ldflags="-extld=${CC}" -v -o bin/power-control ./cmd/power-control; \ else \ + echo "Using native amd64 compiler" && \ + echo "Building without external CC" && \ go build -v -o bin/power-control ./cmd/power-control; \ fi From ef40a892c6b8a900d7916b6f2c2ce4e0a0b3792d Mon Sep 17 00:00:00 2001 From: Alex Lovell-Troy Date: Mon, 1 Jun 2026 13:36:38 -0400 Subject: [PATCH 05/13] Add OCI labels for enhanced container metadata in Dockerfile.build Signed-off-by: Alex Lovell-Troy --- Dockerfile.build | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Dockerfile.build b/Dockerfile.build index c6022ff..df082f6 100644 --- a/Dockerfile.build +++ b/Dockerfile.build @@ -76,6 +76,14 @@ RUN set -ex && \ # TODO seems kinda off that we don't pin wolfi or tini, but whatever FROM chainguard/wolfi-base:latest AS main +# OCI labels for better container metadata +LABEL org.opencontainers.image.title="OpenCHAMI Power Control Service" \ + org.opencontainers.image.description="Multi-architecture power control service for OpenCHAMI (supports linux/amd64 and linux/arm64)" \ + org.opencontainers.image.vendor="OpenCHAMI" \ + org.opencontainers.image.source="https://github.com/OpenCHAMI/power-control" \ + org.opencontainers.image.documentation="https://github.com/OpenCHAMI/power-control/blob/main/README.md" \ + org.opencontainers.image.licenses="MIT" + RUN set -ex \ && apk update \ && apk add --no-cache tini \ From 8c113a3608af0985ed4c119a00e9237b78a36ca3 Mon Sep 17 00:00:00 2001 From: Alex Lovell-Troy Date: Mon, 1 Jun 2026 13:55:40 -0400 Subject: [PATCH 06/13] Update workflow to use specific multi-arch build refinements and enhance image description Signed-off-by: Alex Lovell-Troy --- .github/workflows/upstream-docker-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/upstream-docker-release.yml b/.github/workflows/upstream-docker-release.yml index 0b02938..5f3cc0d 100644 --- a/.github/workflows/upstream-docker-release.yml +++ b/.github/workflows/upstream-docker-release.yml @@ -23,11 +23,11 @@ permissions: write-all # Necessary for the generate-build-provenance action with jobs: image: name: Build & Push Multi-arch Image - uses: OpenCHAMI/github-actions/.github/workflows/docker-build-release.yml@v3.3 + uses: OpenCHAMI/github-actions/.github/workflows/docker-build-release.yml@feature/multi-arch-build-refinements@feature/multi-arch-build-refinements with: fetch-depth: 1 registry-name: ghcr.io/openchami/pcs cgo-enabled: 1 platforms: "linux/amd64,linux/arm64" docker-file: "Dockerfile.build" - # Don't pass CC here - let the Dockerfile set it based on TARGETARCH + image-description: "Multi-architecture power control service for OpenCHAMI (supports linux/amd64 and linux/arm64)" From 528546d789bb946824fa051d50e6a5731c5974fa Mon Sep 17 00:00:00 2001 From: Alex Lovell-Troy Date: Mon, 1 Jun 2026 13:57:14 -0400 Subject: [PATCH 07/13] Fix workflow reference for multi-arch image build in upstream-docker-release.yml Signed-off-by: Alex Lovell-Troy --- .github/workflows/upstream-docker-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/upstream-docker-release.yml b/.github/workflows/upstream-docker-release.yml index 5f3cc0d..f0250e6 100644 --- a/.github/workflows/upstream-docker-release.yml +++ b/.github/workflows/upstream-docker-release.yml @@ -23,7 +23,7 @@ permissions: write-all # Necessary for the generate-build-provenance action with jobs: image: name: Build & Push Multi-arch Image - uses: OpenCHAMI/github-actions/.github/workflows/docker-build-release.yml@feature/multi-arch-build-refinements@feature/multi-arch-build-refinements + uses: OpenCHAMI/github-actions/.github/workflows/docker-build-release.yml@feature/multi-arch-build-refinements with: fetch-depth: 1 registry-name: ghcr.io/openchami/pcs From 7f84dc26fcf5de83bb6b61bdc5d9b74a1274232f Mon Sep 17 00:00:00 2001 From: Alex Lovell-Troy Date: Mon, 1 Jun 2026 14:55:28 -0400 Subject: [PATCH 08/13] Remove GoReleaser build instructions from README.md Signed-off-by: Alex Lovell-Troy --- README.md | 38 +------------------------------------- 1 file changed, 1 insertion(+), 37 deletions(-) diff --git a/README.md b/README.md index 8dbbbbd..1efc292 100644 --- a/README.md +++ b/README.md @@ -1,39 +1,3 @@ # Power Control Service(pcs) -This is a fork of the original PCS code from [Cray-HPE/hms-power-control](https://github.com/Cray-HPE/hms-power-control), suitable only for experimentation and demo purposes at this point. - -## Build/Install with goreleaser - -This project uses [GoReleaser](https://goreleaser.com/) to automate releases and include additional build metadata such as commit info, build time, and versioning. Below is a guide on how to set up and build the project locally using GoReleaser. - -### Environment Variables - -To include detailed build metadata, ensure the following environment variables are set: - -* __GIT_STATE__: Indicates whether there are uncommitted changes in the working directory. Set to clean if the repository is clean, or dirty if there are uncommitted changes. -* __BUILD_HOST__: The hostname of the machine where the build is being performed. -* __GO_VERSION__: The version of Go used for the build. GoReleaser uses this to ensure consistent Go versioning information. -* __BUILD_USER__: The username of the person or system performing the build. - -Set all the environment variables with: -```bash -export GIT_STATE=$(if git diff-index --quiet HEAD --; then echo 'clean'; else echo 'dirty'; fi) -export BUILD_HOST=$(hostname) -export GO_VERSION=$(go version | awk '{print $3}') -export BUILD_USER=$(whoami) -``` - -### Building Locally with GoReleaser - -Once the environment variables are set, you can build the project locally using GoReleaser in snapshot mode (to avoid publishing). - - -Follow the installation instructions from [GoReleaser’s documentation](https://goreleaser.com/install/). - -1. Run GoReleaser in snapshot mode with the --snapshot flag to create a local build without attempting to release it: - ```bash - goreleaser release --snapshot --clean - ``` -2. Check the dist/ directory for the built binaries, which will include the metadata from the environment variables. You can inspect the binary output to confirm that the metadata was correctly embedded. - -__NOTE__ If you see errors, ensure that you are using the same version of goreleaser that is being used in the [Release Action](.github/workflows/Release.yml) \ No newline at end of file +This is a fork of the original PCS code from [Cray-HPE/hms-power-control](https://github.com/Cray-HPE/hms-power-control), suitable only for experimentation and demo purposes at this point. \ No newline at end of file From 3b3ec446abfdf478f74787d2d07fb834af1639c8 Mon Sep 17 00:00:00 2001 From: Alex Lovell-Troy Date: Tue, 2 Jun 2026 06:44:11 -0400 Subject: [PATCH 09/13] Update .github/workflows/upstream-docker-release.yml Co-authored-by: Travis Raines <571832+rainest@users.noreply.github.com> Signed-off-by: Alex Lovell-Troy --- .github/workflows/upstream-docker-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/upstream-docker-release.yml b/.github/workflows/upstream-docker-release.yml index f0250e6..ad038be 100644 --- a/.github/workflows/upstream-docker-release.yml +++ b/.github/workflows/upstream-docker-release.yml @@ -23,7 +23,7 @@ permissions: write-all # Necessary for the generate-build-provenance action with jobs: image: name: Build & Push Multi-arch Image - uses: OpenCHAMI/github-actions/.github/workflows/docker-build-release.yml@feature/multi-arch-build-refinements + uses: OpenCHAMI/github-actions/.github/workflows/docker-build-release.yml@v3.4 with: fetch-depth: 1 registry-name: ghcr.io/openchami/pcs From ee02e7b55bcd04765529d9e156b35b04131d62cb Mon Sep 17 00:00:00 2001 From: Alex Lovell-Troy Date: Tue, 2 Jun 2026 06:44:23 -0400 Subject: [PATCH 10/13] Update Dockerfile.build Co-authored-by: Travis Raines <571832+rainest@users.noreply.github.com> Signed-off-by: Alex Lovell-Troy --- Dockerfile.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.build b/Dockerfile.build index df082f6..5f5a9ab 100644 --- a/Dockerfile.build +++ b/Dockerfile.build @@ -78,7 +78,7 @@ FROM chainguard/wolfi-base:latest AS main # OCI labels for better container metadata LABEL org.opencontainers.image.title="OpenCHAMI Power Control Service" \ - org.opencontainers.image.description="Multi-architecture power control service for OpenCHAMI (supports linux/amd64 and linux/arm64)" \ + org.opencontainers.image.description="OpenCHAMI Power Control Service" \ org.opencontainers.image.vendor="OpenCHAMI" \ org.opencontainers.image.source="https://github.com/OpenCHAMI/power-control" \ org.opencontainers.image.documentation="https://github.com/OpenCHAMI/power-control/blob/main/README.md" \ From 56f1fa0dd309931c23b67a26d6d506fc68891991 Mon Sep 17 00:00:00 2001 From: Alex Lovell-Troy Date: Tue, 2 Jun 2026 06:44:33 -0400 Subject: [PATCH 11/13] Update .github/workflows/upstream-docker-release.yml Co-authored-by: Travis Raines <571832+rainest@users.noreply.github.com> Signed-off-by: Alex Lovell-Troy --- .github/workflows/upstream-docker-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/upstream-docker-release.yml b/.github/workflows/upstream-docker-release.yml index ad038be..73f0186 100644 --- a/.github/workflows/upstream-docker-release.yml +++ b/.github/workflows/upstream-docker-release.yml @@ -30,4 +30,4 @@ jobs: cgo-enabled: 1 platforms: "linux/amd64,linux/arm64" docker-file: "Dockerfile.build" - image-description: "Multi-architecture power control service for OpenCHAMI (supports linux/amd64 and linux/arm64)" + image-description: "OpenCHAMI Power Control Service" From 2793b30d02fd6b5f47fd70310188d84166a60fbb Mon Sep 17 00:00:00 2001 From: Alex Lovell-Troy Date: Tue, 2 Jun 2026 06:44:54 -0400 Subject: [PATCH 12/13] Update README.md Co-authored-by: Travis Raines <571832+rainest@users.noreply.github.com> Signed-off-by: Alex Lovell-Troy --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1efc292..fda83c3 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ # Power Control Service(pcs) -This is a fork of the original PCS code from [Cray-HPE/hms-power-control](https://github.com/Cray-HPE/hms-power-control), suitable only for experimentation and demo purposes at this point. \ No newline at end of file +This is a fork of the original PCS code from [Cray-HPE/hms-power-control](https://github.com/Cray-HPE/hms-power-control). It adds support for Postgres operation. \ No newline at end of file From 023d7d247e3ac548c531330eb78f9c18550cc82b Mon Sep 17 00:00:00 2001 From: Alex Lovell-Troy Date: Tue, 2 Jun 2026 06:45:03 -0400 Subject: [PATCH 13/13] Update README.md Co-authored-by: Travis Raines <571832+rainest@users.noreply.github.com> Signed-off-by: Alex Lovell-Troy --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fda83c3..79410c2 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ -# Power Control Service(pcs) +# Power Control Service (pcs) This is a fork of the original PCS code from [Cray-HPE/hms-power-control](https://github.com/Cray-HPE/hms-power-control). It adds support for Postgres operation. \ No newline at end of file