-
Notifications
You must be signed in to change notification settings - Fork 174
/
build-images-linux.sh
executable file
·52 lines (38 loc) · 1.49 KB
/
build-images-linux.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
set -e
docker buildx create --use
docker run --privileged --rm tonistiigi/binfmt --install all
find artifacts/binaries -type f -exec chmod +x {} \;
PLATFORMS="linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64"
OUTPUT="type=local,dest=local"
TAGS=
TAGS_ALPINE=
if [[ "${GITHUB_REF}" == "refs/heads/master" ]]; then
echo "Building and pushing CI images"
docker login -u lucaslorentz -p "$DOCKER_PASSWORD"
OUTPUT="type=registry"
TAGS="-t lucaslorentz/caddy-docker-proxy:ci"
TAGS_ALPINE="-t lucaslorentz/caddy-docker-proxy:ci-alpine"
fi
if [[ "${GITHUB_REF}" =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+(-.*)?$ ]]; then
RELEASE_VERSION=$(echo $GITHUB_REF | cut -c11-)
echo "Releasing version ${RELEASE_VERSION}..."
docker login -u lucaslorentz -p "$DOCKER_PASSWORD"
PATCH_VERSION=$(echo $RELEASE_VERSION | cut -c2-)
MINOR_VERSION=$(echo $PATCH_VERSION | cut -d. -f-2)
OUTPUT="type=registry"
TAGS="-t lucaslorentz/caddy-docker-proxy:latest \
-t lucaslorentz/caddy-docker-proxy:${PATCH_VERSION} \
-t lucaslorentz/caddy-docker-proxy:${MINOR_VERSION}"
TAGS_ALPINE="-t lucaslorentz/caddy-docker-proxy:alpine \
-t lucaslorentz/caddy-docker-proxy:${PATCH_VERSION}-alpine \
-t lucaslorentz/caddy-docker-proxy:${MINOR_VERSION}-alpine"
fi
docker buildx build -f Dockerfile . \
-o $OUTPUT \
--platform $PLATFORMS \
$TAGS
docker buildx build -f Dockerfile-alpine . \
-o $OUTPUT \
--platform $PLATFORMS \
$TAGS_ALPINE