forked from openwrt/docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-build.sh
executable file
·56 lines (45 loc) · 1.51 KB
/
docker-build.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
#!/bin/bash
set -ex
# Copy Dockerfile inside build context to support older Docker versions
# See https://github.com/docker/cli/pull/886
cp "$DOCKERFILE" ./build/Dockerfile
TMP_IMAGE_NAME=$(tr -dc '[:lower:]' </dev/urandom | fold -w 32 | head -n 1)
docker build \
--build-arg CI_REGISTRY_IMAGE \
--file "./build/Dockerfile" \
--tag "$TMP_IMAGE_NAME" \
./build
for IMAGE in $DOCKER_IMAGE; do
if [ "$TYPE" = "imagebuilder" ] || [ "$TYPE" = "rootfs" ]; then
docker tag "$TMP_IMAGE_NAME" "$IMAGE:$TARGET-$VERSION"
docker tag "$TMP_IMAGE_NAME" "$IMAGE:$TARGET-$BRANCH"
fi
if [ "$TYPE" = "rootfs" ]; then
docker tag "$TMP_IMAGE_NAME" "$IMAGE:$ARCH-$VERSION"
if [ "$VERSION" == "snapshot" ]; then
docker tag "$TMP_IMAGE_NAME" "$IMAGE:$ARCH"
fi
fi
if [ "$TYPE" = "sdk" ]; then
docker tag "$TMP_IMAGE_NAME" "$IMAGE:$ARCH-$VERSION"
docker tag "$TMP_IMAGE_NAME" "$IMAGE:$ARCH-$BRANCH"
if [ "$VERSION" == "snapshot" ]; then
docker tag "$IMAGE:$ARCH-$VERSION" "$IMAGE:$ARCH"
fi
fi
if [ "$TARGET" == "x86-64" ] || [ "$ARCH" == "x86_64" ]; then
docker tag "$TMP_IMAGE_NAME" "$IMAGE:$VERSION"
docker tag "$TMP_IMAGE_NAME" "$IMAGE:$BRANCH"
if [ "$VERSION" == "snapshot" ]; then
docker tag "$TMP_IMAGE_NAME" \
"$IMAGE":"$(echo "$TARGET" | tr '/' '-')"
docker tag "$TMP_IMAGE_NAME" "$IMAGE:latest"
fi
fi
for TARGET_TAG in $TARGETS; do
TARGET_TAG=$(echo "$TARGET_TAG" | tr '/' '-')
docker tag "$TMP_IMAGE_NAME" "$IMAGE:$TARGET_TAG-$VERSION"
done
done
docker rmi "$TMP_IMAGE_NAME"
rm -rf ./build