Skip to content

Commit

Permalink
est
Browse files Browse the repository at this point in the history
  • Loading branch information
alanprot committed Dec 14, 2022
1 parent c7b6794 commit 757de54
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 20 deletions.
1 change: 1 addition & 0 deletions .github/workflows/scripts/install-docker.sh
Expand Up @@ -8,3 +8,4 @@ mkdir -vp ~/.docker/cli-plugins/
curl --silent -L "https://github.com/docker/buildx/releases/download/v0.3.0/buildx-v0.3.0.linux-amd64" > ~/.docker/cli-plugins/docker-buildx
chmod a+x ~/.docker/cli-plugins/docker-buildx
mv /tmp/docker/* /usr/bin
docker run --privileged --rm tonistiigi/binfmt --install all
4 changes: 2 additions & 2 deletions .github/workflows/test-build-deploy.yml
Expand Up @@ -207,8 +207,8 @@ jobs:
GIT_SSH_COMMAND: "ssh -o StrictHostKeyChecking=no"

deploy:
needs: [build, test, lint, integration, integration-configs-db]
if: (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')) && github.repository == 'cortexproject/cortex'
needs: [build]
if: github.repository == 'cortexproject/cortex'
runs-on: ubuntu-20.04
container:
image: quay.io/cortexproject/build-image:upgrade-to-go1.19.3-e8b98ddc0
Expand Down
9 changes: 5 additions & 4 deletions Makefile
Expand Up @@ -37,7 +37,7 @@ SED ?= $(shell which gsed 2>/dev/null || which sed)
# Dependencies (i.e. things that go in the image) still need to be explicitly
# declared.
%/$(UPTODATE): %/Dockerfile
$(SUDO) docker buildx build --platform linux/amd64 --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)/
$(SUDO) docker buildx build --platform linux/amd64 --build-arg=revision=$(GIT_REVISION) --build-arg=goproxyValue=$(GOPROXY_VALUE) -t $(IMAGE_PREFIX)$(shell basename $(@D)) -t $(IMAGE_PREFIX)$(shell basename $(@D)):$(IMAGE_TAG)-amd64 $(@D)/
$(SUDO) docker buildx build --platform linux/arm64 --build-arg=revision=$(GIT_REVISION) --build-arg=goproxyValue=$(GOPROXY_VALUE) -t $(IMAGE_PREFIX)$(shell basename $(@D)) -t $(IMAGE_PREFIX)$(shell basename $(@D)):$(IMAGE_TAG)-arm64 $(@D)/
@echo
@echo Please use push-multiarch-build-image to build and push build image for all supported architectures.
Expand Down Expand Up @@ -160,7 +160,8 @@ else
exes: $(EXES)

$(EXES):
CGO_ENABLED=0 go build $(GO_FLAGS) -o $@ ./$(@D)
CGO_ENABLED=0 go build $(GO_FLAGS) -o $@-amd64 ./$(@D)
CGO_ENABLED=0 GOARCH=arm64 GOOS=linux go build $(GO_FLAGS) -o $@-arm64 ./$(@D)

protos: $(PROTO_GOS)

Expand Down Expand Up @@ -274,15 +275,15 @@ save-images:
@mkdir -p docker-images
for image_name in $(IMAGE_NAMES); do \
if ! echo $$image_name | grep build; then \
docker save $$image_name:$(IMAGE_TAG) -o docker-images/$$(echo $$image_name | tr "/" _):$(IMAGE_TAG); \
docker save $$image_name:$(IMAGE_TAG)-amd64 -o docker-images/$$(echo $$image_name | tr "/" _):$(IMAGE_TAG)-amd64; \
docker save $$image_name:$(IMAGE_TAG)-arm64 -o docker-images/$$(echo $$image_name | tr "/" _):$(IMAGE_TAG)-arm64; \
fi \
done

load-images:
for image_name in $(IMAGE_NAMES); do \
if ! echo $$image_name | grep build; then \
docker load -i docker-images/$$(echo $$image_name | tr "/" _):$(IMAGE_TAG); \
docker load -i docker-images/$$(echo $$image_name | tr "/" _):$(IMAGE_TAG)-amd64; \
docker load -i docker-images/$$(echo $$image_name | tr "/" _):$(IMAGE_TAG)-arm64; \
fi \
done
Expand Down
6 changes: 4 additions & 2 deletions cmd/cortex/Dockerfile
@@ -1,7 +1,9 @@
FROM --platform=$BUILDPLATFORM alpine:3.14
FROM alpine:3.14
ARG TARGETARCH

RUN apk add --no-cache ca-certificates
COPY migrations /migrations/
COPY cortex /bin/cortex
COPY cortex-$TARGETARCH /bin/cortex
EXPOSE 80
ENTRYPOINT [ "/bin/cortex" ]

Expand Down
6 changes: 4 additions & 2 deletions cmd/query-tee/Dockerfile
@@ -1,6 +1,8 @@
FROM --platform=$BUILDPLATFORM alpine:3.14
FROM alpine:3.14
ARG TARGETARCH

RUN apk add --no-cache ca-certificates
COPY query-tee /
COPY query-tee-$TARGETARCH /query-tee
ENTRYPOINT ["/query-tee"]

ARG revision
Expand Down
5 changes: 3 additions & 2 deletions cmd/test-exporter/Dockerfile
@@ -1,6 +1,7 @@
FROM --platform=$BUILDPLATFORM alpine:3.14
FROM alpine:3.14
ARG TARGETARCH
RUN apk add --no-cache ca-certificates
COPY test-exporter /
COPY test-exporter-$TARGETARCH /test-exporter
ENTRYPOINT ["/test-exporter"]

ARG revision
Expand Down
5 changes: 3 additions & 2 deletions cmd/thanosconvert/Dockerfile
@@ -1,6 +1,7 @@
FROM --platform=$BUILDPLATFORM alpine:3.14
FROM alpine:3.14
ARG TARGETARCH
RUN apk add --no-cache ca-certificates
COPY thanosconvert /
COPY thanosconvert-$TARGETARCH /thanosconvert
ENTRYPOINT ["/thanosconvert"]

ARG revision
Expand Down
16 changes: 10 additions & 6 deletions push-images
Expand Up @@ -29,8 +29,11 @@ done

push_image() {
local image="$1"
echo "Pushing ${image}:${IMAGE_TAG}"
docker push ${image}:${IMAGE_TAG}

# for arch in amd64 arm64; do \
# echo "Pushing ${image}:${IMAGE_TAG}-$arch"
# docker push ${image}:${IMAGE_TAG}-$arch
# done;

if [ -n "${NO_QUAY}" ]; then
return
Expand All @@ -39,11 +42,12 @@ push_image() {
# remove the quay prefix and push to docker hub
docker_hub_image=${image#$QUAY_PREFIX}
for arch in amd64 arm64; do \
docker tag ${image}:${IMAGE_TAG} ${docker_hub_image}:${IMAGE_TAG}-$arch

echo "Pushing ${docker_hub_image}:${IMAGE_TAG}-$arch"
docker push ${docker_hub_image}:${IMAGE_TAG}-$arch
docker tag ${image}:${IMAGE_TAG}-$arch ${docker_hub_image}:${IMAGE_TAG}-$arch
done;

echo "Pushing ${docker_hub_image}:${IMAGE_TAG}-$arch"
docker manifest create ${docker_hub_image}:${IMAGE_TAG} --amend ${docker_hub_image}:${IMAGE_TAG}-amd64 --amend ${docker_hub_image}:${IMAGE_TAG}-arm64
docker manifest push ${docker_hub_image}:${IMAGE_TAG}
}

for image in ${IMAGES}; do
Expand Down

0 comments on commit 757de54

Please sign in to comment.