1
0
mirror of https://github.com/xzeldon/vwdump.git synced 2025-06-28 10:58:15 +03:00

Added buildx to allow multi-arch builds

Squashed commit of the following:

commit f3d42ceebe3f209645dc44b9e1ea956339c32968
Author: 1O <2408212-1O@users.noreply.gitlab.com>
Date:   Sun Jan 24 19:48:23 2021 +0100

    Only build master since rpi3 is no longer needed

commit 32e213d65955291fa38d20c77e74aa30cf25cd24
Author: 1O <2408212-1O@users.noreply.gitlab.com>
Date:   Sun Jan 24 19:46:40 2021 +0100

    Added dockerhub login

commit 960c44c7148073cfbee617be3019fb399d1fc0b1
Author: 1O <2408212-1O@users.noreply.gitlab.com>
Date:   Sun Jan 24 19:38:21 2021 +0100

    Added ARCH to Dockerfile

commit fad35cd700dcf7a4c4ee5ac7eeea89f33871eaab
Author: 1O <2408212-1O@users.noreply.gitlab.com>
Date:   Sun Jan 24 19:30:30 2021 +0100

    don't push in buildx

commit 9cd85b6787ec552d5dee393a40137fa3ed9cb94e
Author: 1O <2408212-1O@users.noreply.gitlab.com>
Date:   Sun Jan 24 19:28:09 2021 +0100

    added context

commit 07fb2b320463dc495c4e69f40bb524bcc0ebd15a
Author: 1O <2408212-1O@users.noreply.gitlab.com>
Date:   Sun Jan 24 19:20:02 2021 +0100

    Added experimental

commit 99b352dad13aca54f49fb56f0fb19a921cd81c9d
Author: 1O <2408212-1O@users.noreply.gitlab.com>
Date:   Sun Jan 24 19:16:59 2021 +0100

    Added buildx
This commit is contained in:
1O 2021-01-24 19:49:51 +01:00
parent 6621785c90
commit 026ef778b6
No known key found for this signature in database
GPG Key ID: 6D48F9802A5457C8
2 changed files with 23 additions and 26 deletions

View File

@ -7,6 +7,9 @@ variables:
# see https://gitlab.com/gitlab-org/gitlab-runner/issues/4501
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: "/certs"
# See https://github.com/docker/buildx/releases
BUILDX_VERSION: v0.5.1
BUILDX_ARCH: linux-amd64
.docker_login: &docker_login
docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
@ -18,37 +21,29 @@ variables:
stage: build:docker
image: docker:latest
services:
- docker:dind
- name: docker:dind
command: ["--experimental"]
tags:
- shared
before_script:
- apk add curl
- mkdir -p ~/.docker/cli-plugins
- curl -sSLo ~/.docker/cli-plugins/docker-buildx https://github.com/docker/buildx/releases/download/$BUILDX_VERSION/buildx-$BUILDX_VERSION.$BUILDX_ARCH
- chmod +x ~/.docker/cli-plugins/docker-buildx
- docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- docker context create my-context
- docker buildx create --use my-context
- docker info
build_master:
<<: *docker_build
script:
- *docker_login
- docker build --pull -t "$IMAGE_NAME" -t "$IMAGE_NAME_DOCKERHUB:${CI_COMMIT_TAG:-latest}" .
- docker push "$IMAGE_NAME"
- *dockerhub_login
- docker push "$IMAGE_NAME_DOCKERHUB:${CI_COMMIT_TAG:-latest}"
only:
refs:
- master
- tags
changes:
- Dockerfile
- backup.sh
- entrypoint.sh
build_master_rpi3:
<<: *docker_build
script:
- *docker_login
- docker build --pull -t "$IMAGE_NAME:rpi3" -t "$IMAGE_NAME_DOCKERHUB:${CI_COMMIT_TAG:-latest}-rpi3" .
- docker push "$IMAGE_NAME:rpi3"
- *dockerhub_login
- docker push "$IMAGE_NAME_DOCKERHUB:${CI_COMMIT_TAG:-latest}-rpi3"
tags:
- rpi3
#- docker build --pull -t "$IMAGE_NAME" -t "$IMAGE_NAME_DOCKERHUB:${CI_COMMIT_TAG:-latest}" .
- docker buildx build --push --platform linux/arm/v7,linux/arm64/v8,linux/amd64 -t "$IMAGE_NAME" -t "$IMAGE_NAME_DOCKERHUB:${CI_COMMIT_TAG:-latest}" .
#- docker push "$IMAGE_NAME"
#- docker push "$IMAGE_NAME_DOCKERHUB:${CI_COMMIT_TAG:-latest}"
only:
refs:
- master
@ -62,8 +57,9 @@ build:
<<: *docker_build
script:
- *docker_login
- docker build --pull -t "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG/bw_backup:${CI_COMMIT_TAG:-latest}" .
- docker push "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG/bw_backup:${CI_COMMIT_TAG:-latest}"
#- docker build --pull -t "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG/bw_backup:${CI_COMMIT_TAG:-latest}" .
- docker buildx build --push --platform linux/arm/v7,linux/arm64/v8,linux/amd64 --tag "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG/bw_backup:${CI_COMMIT_TAG:-latest}" .
#- docker push "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG/bw_backup:${CI_COMMIT_TAG:-latest}"
except:
- master

View File

@ -1,4 +1,5 @@
FROM alpine:latest
ARG ARCH=
FROM ${ARCH}alpine:latest
RUN addgroup -S app && adduser -S -G app app