Commit 6e2e6a98 authored by Carlo Landmeter's avatar Carlo Landmeter
Browse files

add gitlab ci

parent 0c11a9e3
Pipeline #4616 failed with stages
in 8 minutes and 11 seconds
image: alpinelinux/docker-cli
stages:
- build
- push
- manifest
- cleanup
# Build jobs
build-v3.8:
stage: build
script:
- ./make_images.sh build v3.8
build-v3.9:
stage: build
script:
- ./make_images.sh build v3.9
build-v3.10:
stage: build
script:
- ./make_images.sh build v3.10
build-v.3.11:
stage: build
script:
- ./make_images.sh build v3.11
build-edge:
stage: build
script:
- ./make_images.sh build edge
# Push jobs
push-v3.8:
stage: push
script:
- ./make_images.sh push v3.8
push-v3.9:
stage: push
script:
- ./make_images.sh push v3.9
push-v3.10:
stage: push
script:
- ./make_images.sh push v3.10
push-v.3.11:
stage: push
script:
- ./make_images.sh push v3.11
push-edge:
stage: push
script:
- ./make_images.sh push edge
manifest-v3.8:
stage: manifest
variables:
DOCKER_CLI_EXPERIMENTAL: enabled
script:
- ./make_images.sh manifest v3.8
manifest-v3.9:
stage: manifest
variables:
DOCKER_CLI_EXPERIMENTAL: enabled
script:
- ./make_images.sh manifest v3.9
manifest-v3.10:
stage: manifest
variables:
DOCKER_CLI_EXPERIMENTAL: enabled
script:
- ./make_images.sh manifest v3.10
manifest-v3.11:
stage: manifest
variables:
DOCKER_CLI_EXPERIMENTAL: enabled
script:
- ./make_images.sh manifest v3.11
manifest-edge:
stage: manifest
variables:
DOCKER_CLI_EXPERIMENTAL: enabled
script:
- ./make_images.sh manifest edge
# cleanup images/layers
cleanup:
stage: cleanup
script:
- docker system prune --force
FROM alpine:%%ALPINE_TAG%%
FROM %%ALPINE_IMG%%/alpine:%%ALPINE_TAG%%
MAINTAINER Richard Mortier <mort@cantab.net>
RUN rm /etc/apk/repositories && \
......
#!/bin/sh
set -eu
readonly NAMESPACE="${NAMESPACE:=alpinelinux}"
readonly PROJECT="${PROJECT:=docker-alpine}"
readonly ARCHES="${ARCHES:=x86 x86_64 armhf armv7 aarch64 ppc64le s390x}"
readonly TEMPLATE="Dockerfile.in"
readonly OPERATION="$1"
readonly RELEASE="$2"
die() {
echo "$1" >&2
exit 1
}
arch_to_image() {
case $1 in
armv7) echo arm32v7 ;;
aarch64) echo arm64v8 ;;
x86_64) echo amd64 ;;
armhf) echo arm32v6 ;;
x86) echo i386 ;;
ppc64le) echo ppc64le ;;
s390x) echo s390x ;;
*) die "Unknown arch detected: \"$1\""
esac
}
build() {
for arch in $ARCHES; do
[ "$RELEASE" = "v3.8" ] && [ "$arch" = "armv7" ] && continue
sed -e "s/%%ALPINE_IMG%%/$(arch_to_image $arch)/" \
-e "s/%%ALPINE_TAG%%/${RELEASE/v/}/" \
-e "s/%%ALPINE_REL%%/$RELEASE/" "$TEMPLATE" > Dockerfile
docker build --no-cache -t "$NAMESPACE/$PROJECT:$RELEASE-$arch" . || \
die "Failed to build docker-abuild:$RELEASE-$arch"
done
}
push() {
printf "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" \
--password-stdin || die "Failed to login to docker hub"
for arch in $ARCHES; do
[ "$RELEASE" = "v3.8" ] && [ "$arch" = "armv7" ] && continue
docker push "$NAMESPACE/$PROJECT:$RELEASE-$arch" || \
die "Failed to push docker-abuild:$RELEASE-$arch"
done
}
manifest() {
local images= arch=
printf "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" \
--password-stdin || die "Failed to login to docker hub"
for arch in $ARCHES; do
[ "$RELEASE" = "v3.8" ] && [ "$arch" = "armv7" ] && continue
images="$images $NAMESPACE/$PROJECT:$RELEASE-$arch"
done
docker manifest create --amend "$NAMESPACE/$PROJECT" $images || \
die "Failed to create manifest"
docker manifest push --purge "$NAMESPACE/$PROJECT" || \
die "Failed to push manifest"
}
[ "$RELEASE" ] || die "Second argument needs to be a alpine release"
case $OPERATION in
build) build ;;
push) push ;;
manifest) manifest ;;
*) die "First argument needs to be build|push|manifest" ;;
esac
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment