Skip to content

Commit 5ca5073

Browse files
committed
Building Arm Images (#5041)
* wip Signed-off-by: Alan Protasio <[email protected]> * est Signed-off-by: Alan Protasio <[email protected]> * quay Signed-off-by: Alan Protasio <[email protected]> * using different repository for the archteture specific images Signed-off-by: Alan Protasio <[email protected]> * testing linux repos Signed-off-by: Alan Protasio <[email protected]> * testing manifes on both platforms Signed-off-by: Alan Protasio <[email protected]> * enabling deploy stage only on master Signed-off-by: Alan Protasio <[email protected]> * changelog Signed-off-by: Alan Protasio <[email protected]> * using amd64 image for e2e teests Signed-off-by: Alan Protasio <[email protected]> Signed-off-by: Alan Protasio <[email protected]>
1 parent b172377 commit 5ca5073

File tree

9 files changed

+54
-17
lines changed

9 files changed

+54
-17
lines changed

.github/workflows/scripts/install-docker.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,8 @@ set -x
44
VER="18.06.3-ce"
55
curl -L -o /tmp/docker-$VER.tgz https://download.docker.com/linux/static/stable/x86_64/docker-$VER.tgz
66
tar -xz -C /tmp -f /tmp/docker-$VER.tgz
7+
mkdir -vp ~/.docker/cli-plugins/
8+
curl --silent -L "https://github.com/docker/buildx/releases/download/v0.3.0/buildx-v0.3.0.linux-amd64" > ~/.docker/cli-plugins/docker-buildx
9+
chmod a+x ~/.docker/cli-plugins/docker-buildx
710
mv /tmp/docker/* /usr/bin
11+
docker run --privileged --rm tonistiigi/binfmt --install all

.github/workflows/test-build-deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ jobs:
145145
run: |
146146
export CORTEX_IMAGE_PREFIX="${IMAGE_PREFIX:-quay.io/cortexproject/}"
147147
export IMAGE_TAG=$(make image-tag)
148-
export CORTEX_IMAGE="${CORTEX_IMAGE_PREFIX}cortex:$IMAGE_TAG"
148+
export CORTEX_IMAGE="${CORTEX_IMAGE_PREFIX}cortex:$IMAGE_TAG-amd64"
149149
export CORTEX_CHECKOUT_DIR="/go/src/github.com/cortexproject/cortex"
150150
echo "Running integration tests with image: $CORTEX_IMAGE"
151151
go test -tags=requires_docker -timeout 2400s -v -count=1 ./integration/...

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# Changelog
22

3+
<<<<<<< HEAD
34
## 1.13.2 2022-12-18
45

56
* [CHANGE] Alertmanager: Local file disclosure vulnerability in OpsGenie configuration has been fixed. #5045
67

78
## 1.13.1 2022-10-03
89
* [BUGFIX] AlertManager: fixed issue introduced by #4495 where templates files were being deleted when using alertmanager local store. #4890
10+
* [FEATURE] Build ARM docker images. #5041
911

1012
## 1.13.0 2022-07-14
1113
* [CHANGE] Changed default for `-ingester.min-ready-duration` from 1 minute to 15 seconds. #4539

Makefile

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
VERSION=$(shell cat "./VERSION" 2> /dev/null)
1010
GOPROXY_VALUE=$(shell go env GOPROXY)
1111

12+
# ARCHS
13+
ARCHS = amd64 arm64
14+
1215
# Boiler plate for building Docker containers.
1316
# All this must go at top of file I'm afraid.
1417
IMAGE_PREFIX ?= quay.io/cortexproject/
@@ -37,8 +40,9 @@ SED ?= $(shell which gsed 2>/dev/null || which sed)
3740
# Dependencies (i.e. things that go in the image) still need to be explicitly
3841
# declared.
3942
%/$(UPTODATE): %/Dockerfile
40-
@echo
41-
$(SUDO) docker build --build-arg=revision=$(GIT_REVISION) --build-arg=goproxyValue=$(GOPROXY_VALUE) -t $(IMAGE_PREFIX)$(shell basename $(@D)) -t $(IMAGE_PREFIX)$(shell basename $(@D)):$(IMAGE_TAG) $(@D)/
43+
for arch in $(ARCHS); do \
44+
$(SUDO) docker buildx build --platform linux/$$arch --build-arg=revision=$(GIT_REVISION) --build-arg=goproxyValue=$(GOPROXY_VALUE) -t $(IMAGE_PREFIX)$(shell basename $(@D)) -t $(IMAGE_PREFIX)$(shell basename $(@D)):$(IMAGE_TAG)-$$arch $(@D)/ ; \
45+
done
4246
@echo
4347
@echo Please use push-multiarch-build-image to build and push build image for all supported architectures.
4448
touch $@
@@ -161,7 +165,11 @@ else
161165
exes: $(EXES)
162166

163167
$(EXES):
164-
CGO_ENABLED=0 go build $(GO_FLAGS) -o $@ ./$(@D)
168+
@for arch in $(ARCHS); do \
169+
echo "Building $@ for $$arch";\
170+
CGO_ENABLED=0 GOARCH=$$arch GOOS=linux go build $(GO_FLAGS) -o $@-$$arch ./$(@D); \
171+
done
172+
165173

166174
protos: $(PROTO_GOS)
167175

@@ -271,16 +279,20 @@ clean-protos:
271279

272280
save-images:
273281
@mkdir -p docker-images
274-
for image_name in $(IMAGE_NAMES); do \
282+
@for image_name in $(IMAGE_NAMES); do \
275283
if ! echo $$image_name | grep build; then \
276-
docker save $$image_name:$(IMAGE_TAG) -o docker-images/$$(echo $$image_name | tr "/" _):$(IMAGE_TAG); \
284+
for arch in $(ARCHS); do \
285+
docker save $$image_name:$(IMAGE_TAG)-$$arch -o docker-images/$$(echo $$image_name | tr "/" _):$(IMAGE_TAG)-$$arch; \
286+
done;\
277287
fi \
278288
done
279289

280290
load-images:
281-
for image_name in $(IMAGE_NAMES); do \
291+
@for image_name in $(IMAGE_NAMES); do \
282292
if ! echo $$image_name | grep build; then \
283-
docker load -i docker-images/$$(echo $$image_name | tr "/" _):$(IMAGE_TAG); \
293+
for arch in $(ARCHS); do \
294+
docker load -i docker-images/$$(echo $$image_name | tr "/" _):$(IMAGE_TAG)-$$arch; \
295+
done;\
284296
fi \
285297
done
286298

cmd/cortex/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
FROM alpine:3.14
2+
ARG TARGETARCH
3+
24
RUN apk add --no-cache ca-certificates
35
COPY migrations /migrations/
4-
COPY cortex /bin/cortex
6+
COPY cortex-$TARGETARCH /bin/cortex
57
EXPOSE 80
68
ENTRYPOINT [ "/bin/cortex" ]
79

cmd/query-tee/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
FROM alpine:3.14
2+
ARG TARGETARCH
3+
24
RUN apk add --no-cache ca-certificates
3-
COPY query-tee /
5+
COPY query-tee-$TARGETARCH /query-tee
46
ENTRYPOINT ["/query-tee"]
57

68
ARG revision

cmd/test-exporter/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
FROM alpine:3.14
2+
ARG TARGETARCH
23
RUN apk add --no-cache ca-certificates
3-
COPY test-exporter /
4+
COPY test-exporter-$TARGETARCH /test-exporter
45
ENTRYPOINT ["/test-exporter"]
56

67
ARG revision

cmd/thanosconvert/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
FROM alpine:3.14
2+
ARG TARGETARCH
23
RUN apk add --no-cache ca-certificates
3-
COPY thanosconvert /
4+
COPY thanosconvert-$TARGETARCH /thanosconvert
45
ENTRYPOINT ["/thanosconvert"]
56

67
ARG revision

push-images

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,32 @@ done
2929

3030
push_image() {
3131
local image="$1"
32-
echo "Pushing ${image}:${IMAGE_TAG}"
33-
docker push ${image}:${IMAGE_TAG}
32+
33+
for arch in amd64 arm64; do \
34+
echo "Pushing ${image}-linux:${IMAGE_TAG}-$arch"
35+
docker tag ${image}:${IMAGE_TAG}-$arch ${image}-linux:${IMAGE_TAG}-$arch
36+
docker push ${image}-linux:${IMAGE_TAG}-$arch
37+
done;
38+
39+
docker manifest create ${image}:${IMAGE_TAG} --amend ${image}-linux:${IMAGE_TAG}-amd64 --amend ${image}-linux:${IMAGE_TAG}-arm64
40+
docker manifest push ${image}:${IMAGE_TAG}
41+
3442

3543
if [ -n "${NO_QUAY}" ]; then
3644
return
3745
fi
3846

3947
# remove the quay prefix and push to docker hub
4048
docker_hub_image=${image#$QUAY_PREFIX}
41-
docker tag ${image}:${IMAGE_TAG} ${docker_hub_image}:${IMAGE_TAG}
49+
for arch in amd64 arm64; do \
50+
docker tag ${image}:${IMAGE_TAG}-$arch ${docker_hub_image}-linux:${IMAGE_TAG}-$arch
51+
52+
echo "Pushing ${docker_hub_image}-linux:${IMAGE_TAG}-$arch"
53+
docker push ${docker_hub_image}-linux:${IMAGE_TAG}-$arch
54+
done;
4255

43-
echo "Pushing ${docker_hub_image}:${IMAGE_TAG}"
44-
docker push ${docker_hub_image}:${IMAGE_TAG}
56+
docker manifest create ${docker_hub_image}:${IMAGE_TAG} --amend ${docker_hub_image}-linux:${IMAGE_TAG}-amd64 --amend ${docker_hub_image}-linux:${IMAGE_TAG}-arm64
57+
docker manifest push ${docker_hub_image}:${IMAGE_TAG}
4558
}
4659

4760
for image in ${IMAGES}; do

0 commit comments

Comments
 (0)