When I build the docker image from source using build-docker-full, it seems the image only works on amd64 systems.
Is there an easy way to build this for arm64?
When I build the docker image from source using build-docker-full, it seems the image only works on amd64 systems.
Is there an easy way to build this for arm64?
Platform variable is hardcoded in the Makefile. So try to edit it.
So i changed line 169 of the makefile to linux/arm64/v8 as shown here:
##@ Docker
TAG_SUFFIX=$(if $(WIRE_TAGS)!=oss,-$(WIRE_TAGS))
PLATFORM=linux/arm64/v8
build-docker-full: ## Build Docker image for development.
@echo "build docker container"
tar -ch . | \
docker buildx build - \
--platform $(PLATFORM) \
--build-arg BINGO=false \
--build-arg GO_BUILD_TAGS=$(GO_BUILD_TAGS) \
--build-arg WIRE_TAGS=$(WIRE_TAGS) \
--build-arg COMMIT_SHA=$$(git rev-parse --short HEAD) \
--build-arg BUILD_BRANCH=$$(git rev-parse --abbrev-ref HEAD) \
--tag grafana/grafana$(TAG_SUFFIX):935arm \
$(DOCKER_BUILD_ARGS)
but i get the following build errors, any ideas what this might mean?
type or paste cobuild docker container
tar -ch . | \
docker buildx build - \
--platform linux/arm64/v8 \
--build-arg BINGO=false \
--build-arg GO_BUILD_TAGS= \
--build-arg WIRE_TAGS="oss" \
--build-arg COMMIT_SHA=$(git rev-parse --short HEAD) \
--build-arg BUILD_BRANCH=$(git rev-parse --abbrev-ref HEAD) \
--tag grafana/grafana-"oss":935arm \
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
[+] Building 6.5s (19/48)
=> [internal] load remote build context 2.9s
=> copy /context / 0.3s
=> resolve image config for docker.io/docker/dockerfile:1 0.7s
=> CACHED docker-image://docker.io/docker/dockerfile:1@sha256:39b85bbfa7 0.0s
=> [internal] load metadata for docker.io/library/alpine:3.17 0.4s
=> [internal] load metadata for docker.io/library/node:18-alpine3.17 0.5s
=> [internal] load metadata for docker.io/library/golang:1.20.4-alpine3. 0.5s
=> [js-builder 1/12] FROM docker.io/library/node:18-alpine3.17@sha256:b 0.0s
=> [stage-5 1/9] FROM docker.io/library/alpine:3.17@sha256:124c7d2707904 0.0s
=> CANCELED [go-builder 1/19] FROM docker.io/library/golang:1.20.4-alpi 0.5s
=> => resolve docker.io/library/golang:1.20.4-alpine3.17@sha256:913de967 0.2s
=> => sha256:4b693cffa390c8021b16cb1258e8d188c9782572578 1.16kB / 1.16kB 0.0s
=> => sha256:0dca8eed3c7cb57d13557f5c2f2c44e675c1316e4d5 5.13kB / 5.13kB 0.0s
=> => sha256:ed15518f570754b8336aff46024845ecb67da1ab7729e 0B / 286.26kB 0.9s
=> => sha256:139a4d6a7f082b9706952969f75879d315c8c6c03c7b7c 0B / 96.03MB 0.9s
=> => sha256:fb5459d8512831b7822b309d7acd7aa3a87c6397dd6c10431 0B / 156B 0.9s
=> => sha256:913de96707b0460bcfdfe422796bb6e559fc300f6c5 1.65kB / 1.65kB 0.0s
=> CACHED [stage-5 2/9] WORKDIR /usr/share/grafana 0.0s
=> ERROR [stage-5 3/9] RUN if grep -i -q alpine /etc/issue; then a 0.5s
=> CACHED [js-builder 2/12] WORKDIR /tmp/grafana 0.0s
=> CACHED copy /context / 0.0s
=> CACHED [js-builder 3/12] COPY package.json yarn.lock .yarnrc.yml ./ 0.0s
=> CACHED [js-builder 4/12] COPY .yarn .yarn 0.0s
=> CACHED [js-builder 5/12] COPY packages packages 0.0s
=> CACHED [js-builder 6/12] COPY plugins-bundled plugins-bundled 0.0s
=> CANCELED [js-builder 7/12] RUN yarn install --immutable 0.8s
------
> [stage-5 3/9] RUN if grep -i -q alpine /etc/issue; then apk add --no-cache ca-certificates bash curl tzdata musl-utils && apk info -vv | sort; elif grep -i -q ubuntu /etc/issue; then DEBIAN_FRONTEND=noninteractive && apt-get update && apt-get install -y ca-certificates curl tzdata && apt-get autoremove -y && rm -rf /var/lib/apt/lists/*; else echo 'ERROR: Unsupported base image' && /bin/false; fi:
#0 0.379 exec /bin/sh: exec format error
------
Dockerfile:107
--------------------
106 | # Install dependencies
107 | >>> RUN if grep -i -q alpine /etc/issue; then \
108 | >>> apk add --no-cache ca-certificates bash curl tzdata musl-utils && \
109 | >>> apk info -vv | sort; \
110 | >>> elif grep -i -q ubuntu /etc/issue; then \
111 | >>> DEBIAN_FRONTEND=noninteractive && \
112 | >>> apt-get update && \
113 | >>> apt-get install -y ca-certificates curl tzdata && \
114 | >>> apt-get autoremove -y && \
115 | >>> rm -rf /var/lib/apt/lists/*; \
116 | >>> else \
117 | >>> echo 'ERROR: Unsupported base image' && /bin/false; \
118 | >>> fi
119 |
--------------------
ERROR: failed to solve: process "/bin/sh -c if grep -i -q alpine /etc/issue; then apk add --no-cache ca-certificates bash curl tzdata musl-utils && apk info -vv | sort; elif grep -i -q ubuntu /etc/issue; then DEBIAN_FRONTEND=noninteractive && apt-get update && apt-get install -y ca-certificates curl tzdata && apt-get autoremove -y && rm -rf /var/lib/apt/lists/*; else echo 'ERROR: Unsupported base image' && /bin/false; fi" did not complete successfully: exit code: 1
make: *** [Makefile:173: build-docker-full] Error 1
de here
Dunno - are you building on amd64 machine? I would try to run plain docker build
on that arm64 machine directly.
Did you download zipfile of the git repo or did git clone?
thanks! appears to be working, unfortunately im building on a pi and im not sure it will finish in this lifetime (10hrs so far) i think ill have to set up an arm vm or something.
also, in the dockerfile i changed
#ARG JS_PLATFORM=linux/amd64
ARG JS_PLATFORM=linux/arm64/v8
and in the makefile
##@ Docker
TAG_SUFFIX=$(if $(WIRE_TAGS)!=oss,-$(WIRE_TAGS))
#PLATFORM=linux/amd64
PLATFORM=linux/arm64/v8
update: unfortunately this did not work after all, it just took much longer to reach an error than when building on my desktop
I would use free tier Oracle OCI Ampere instance (it is arm, but I think not exactly arm64/v8) for quick testing - you will have much more power (4 OCPUs and 24 GB of memory) to test it before running on slow RPI.
IMHO you can build frontend part on any platform (output is just html/css/js), but backend (golang) must be built for arm64/v8. Check makefile and you may find right commands (but it won’t be easy way as you requested in the original post).