From 553d4da0eca39bf07f1cf5c5599551c7a9f87cca Mon Sep 17 00:00:00 2001 From: leonnicolas Date: Fri, 13 Nov 2020 09:14:12 +0100 Subject: [PATCH] .travis.yml: create multi arch image and docker manifest Now you can just pull the image from an arm64 (armV8), arm(armV7) or amd64 architecture without specifying any tag. --- .travis.yml | 16 +++++++++++++--- Dockerfile | 3 ++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index e1f6a71..d101271 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,16 @@ services: script: - docker login -u="$DOCKER_USER" -p="$DOCKER_PW" https://flotte-docker-registry.spdns.org/ - - docker build -t frontend-server . - - docker tag frontend-server flotte-docker-registry.spdns.org/frontend-server - - docker push flotte-docker-registry.spdns.org/frontend-server:latest + - docker build -t frontend-server:amd64 . --build-arg ARCH=amd64 + - docker build -t frontend-server:arm . --build-arg ARCH=arm + - docker build -t frontend-server:arm64 . --build-arg ARCH=arm64 + - docker tag frontend-server:amd64 flotte-docker-registry.spdns.org/frontend-server:amd64 + - docker push flotte-docker-registry.spdns.org/frontend-server:amd64 + - docker tag frontend-server flotte-docker-registry.spdns.org/frontend-server:arm64 + - docker push flotte-docker-registry.spdns.org/frontend-server:arm64 + - docker tag frontend-server flotte-docker-registry.spdns.org/frontend-server:arm + - docker push flotte-docker-registry.spdns.org/frontend-server:arm + - docker manifest create --amend flotte-docker-registry.spdns.org/frontend-server:latest flotte-docker-registry.spdns.org/frontend-server:arm flotte-docker-registry.spdns.org/frontend-server:arm64 flotte-docker-registry.spdns.org/frontend-server:amd64 + - docker manifest annotate flotte-docker-registry.spdns.org/frontend-server:latest flotte-docker-registry.spdns.org/frontend-server:arm --os linux --arch arm --variant v7 + - docker manifest annotate flotte-docker-registry.spdns.org/frontend-server:latest flotte-docker-registry.spdns.org/frontend-server:arm64 --os linux --arch arm64 --variant v8 + - docker manifest push flotte-docker-registry.spdns.org/frontend-server:latest diff --git a/Dockerfile b/Dockerfile index 649fd72..62c6f31 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,6 +9,7 @@ COPY . . RUN ng build --prod --crossOrigin=anonymous FROM golang:1.13.4-alpine as builder2 +ENV ARCH=amd64 RUN apk add git WORKDIR / COPY --from=builder /frontend/dist /dist @@ -16,7 +17,7 @@ RUN go get github.com/rakyll/statik RUN statik --src=/dist/flotte-frontend COPY *.go *.sum *.mod / COPY vendor /vendor -RUN CGO_ENABLED=0 GOOS=linux go build --mod=vendor -o frontend_server +RUN CGO_ENABLED=0 GOARCH=$ARCH GOOS=linux go build --mod=vendor -o frontend_server FROM scratch WORKDIR /