Skip to content

Commit 314d851

Browse files
committed
fix: make targets run on arm64 architecture
Signed-off-by: Oleksii Kurinnyi <[email protected]>
1 parent f8cc347 commit 314d851

File tree

4 files changed

+74
-2
lines changed

4 files changed

+74
-2
lines changed

Makefile

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ OPM_VERSION = v1.19.5
5252

5353
CRD_OPTIONS ?= "crd:crdVersions=v1"
5454

55+
GOOS = linux
56+
GOARCH = amd64
57+
5558
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
5659
ifeq (,$(shell go env GOBIN))
5760
GOBIN=$(shell go env GOPATH)/bin
@@ -187,7 +190,21 @@ docker: _print_vars docker-build docker-push
187190

188191
### docker-build: Builds the controller image
189192
docker-build:
190-
$(DOCKER) build . -t ${DWO_IMG} -f build/Dockerfile
193+
if [ "$(ARCH)" = "arm64" ]; then \
194+
# build natively only the first stage
195+
$(DOCKER) build . --target builder -t devworkspace-builder:temp -f build/Dockerfile; \
196+
# create a container from the temporary image
197+
$(DOCKER) create --name temp-builder devworkspace-builder:temp; \
198+
# copy the binaries to a new local directory
199+
$(DOCKER) cp temp-builder:/devworkspace-operator/_output/bin ./_output; \
200+
# remove the temporary container
201+
$(DOCKER) rm temp-builder; \
202+
$(DOCKER) build . --platform linux/amd64 -t ${DWO_IMG} -f build/Dockerfile.arm; \
203+
# remove the temporary directory
204+
#rm -rf ./_output; \
205+
else \
206+
$(DOCKER) build . -t ${DWO_IMG} -f build/Dockerfile; \
207+
fi
191208

192209
### docker-push: Pushes the controller image
193210
docker-push:

build/Dockerfile.arm64

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#
2+
# Copyright (c) 2019-2025 Red Hat, Inc.
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
16+
# https://access.redhat.com/containers/?tab=tags#/registry.access.redhat.com/ubi9-minimal
17+
FROM registry.access.redhat.com/ubi9-minimal:9.6-1749489516
18+
RUN microdnf -y update && \
19+
microdnf clean all && \
20+
rm -rf /var/cache/yum && \
21+
echo "Installed Packages" && \
22+
rpm -qa | sort -V && \
23+
echo "End Of Installed Packages"
24+
WORKDIR /
25+
COPY _output/bin/devworkspace-controller /usr/local/bin/devworkspace-controller
26+
COPY _output/bin/webhook-server /usr/local/bin/webhook-server
27+
28+
ENV USER_UID=1001 \
29+
USER_NAME=devworkspace-controller
30+
31+
COPY build/bin /usr/local/bin
32+
RUN /usr/local/bin/user_setup
33+
34+
USER ${USER_UID}
35+
36+
ENTRYPOINT ["/usr/local/bin/entrypoint"]
37+
CMD ["/usr/local/bin/devworkspace-controller"]

build/index.next.Dockerfile.arm64

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# The base image is expected to contain
2+
# /bin/opm (with a serve subcommand) and /bin/grpc_health_probe
3+
FROM quay.io/operator-framework/opm:latest
4+
5+
# Configure the entrypoint and command
6+
ENTRYPOINT ["/bin/opm"]
7+
CMD ["serve", "/configs"]
8+
9+
# Copy declarative config root into image at /configs
10+
ADD olm-catalog/next /configs
11+
12+
# Set DC-specific label for the location of the DC root directory
13+
# in the image
14+
LABEL operators.operatorframework.io.index.configs.v1=/configs

build/scripts/build_index_image.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ else
105105
INDEX_IMAGE="${INDEX_IMAGE:-DEFAULT_INDEX_IMAGE}"
106106
OUTDIR="olm-catalog/next"
107107
DOCKERFILE="build/index.next.Dockerfile"
108+
109+
if [ "${ARCH}" = "arm64" ]; then
110+
DOCKERFILE="build/index.next.Dockerfile.arm64"
111+
fi
108112
fi
109113

110114
BUNDLE_IMAGE="${BUNDLE_REPO}:${BUNDLE_TAG}"
@@ -209,7 +213,7 @@ if [ "$MULTI_ARCH" == "true" ]; then
209213
--platform "$ARCHITECTURES" \
210214
--push
211215
else
212-
$PODMAN build . -t "$INDEX_IMAGE" -f "$DOCKERFILE"
216+
$PODMAN build . --platform linux/amd64 -t "$INDEX_IMAGE" -f "$DOCKERFILE"
213217
$PODMAN push "$INDEX_IMAGE" 2>&1
214218
fi
215219

0 commit comments

Comments
 (0)