-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathbuild-docker.sh
executable file
·70 lines (58 loc) · 1.51 KB
/
build-docker.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env bash
# build-docker.sh
#
# SUMMARY
#
# Builds the Vector docker images and optionally
# pushes it to the Docker registry
set -eux
CHANNEL=$(scripts/util/release-channel.sh)
VERSION=$(scripts/version.sh)
DATE=$(date -u +%Y-%m-%d)
PUSH=${PUSH:-}
PLATFORM=${PLATFORM:-}
#
# Functions
#
build() {
base=$1
version=$2
if [ -n "$PLATFORM" ]; then
export DOCKER_CLI_EXPERIMENTAL=enabled
docker run --rm --privileged docker/binfmt:66f9012c56a8316f9244ffd7622d7c21c1f6f28d
docker buildx rm vector-builder || true
docker buildx create --use --name vector-builder
docker buildx install
docker buildx build \
--platform="$PLATFORM" \
--tag timberio/vector:$version-$base \
target/artifacts \
-f distribution/docker/$base/Dockerfile ${PUSH:+--push}
else
docker build \
--tag timberio/vector:$version-$base \
target/artifacts \
-f distribution/docker/$base/Dockerfile
if [ -n "$PUSH" ]; then
docker push timberio/vector:$version-$base
fi
fi
}
#
# Build
#
echo "Building timberio/vector:* Docker images"
if [[ "$CHANNEL" == "latest" ]]; then
version_exact=$VERSION
version_minor_x=$(echo $VERSION | sed 's/\.[0-9]*$/.X/g')
version_major_x=$(echo $VERSION | sed 's/\.[0-9]*\.[0-9]*$/.X/g')
for i in $version_exact $version_minor_x $version_major_x latest; do
build alpine $i
build debian $i
done
elif [[ "$CHANNEL" == "nightly" ]]; then
for i in nightly-$DATE nightly; do
build alpine $i
build debian $i
done
fi