-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·48 lines (41 loc) · 2.21 KB
/
build.sh
File metadata and controls
executable file
·48 lines (41 loc) · 2.21 KB
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
#!/usr/bin/env bash
set -euxo pipefail
apt update && apt install -y buildah fuse-overlayfs netavark iptables
mkdir -p /etc/containers && printf \
"[registries.search]\nregistries = [\"docker.io\", \"quay.io\"]\n" \
> /etc/containers/registries.conf
echo "$OCI_PASS" | \
buildah login -u "$OCI_USER" --password-stdin "https://$OCI_HOST"
echo "$OCI_CACHE_PASS" | \
buildah login -u "$OCI_CACHE_USER" --password-stdin "https://$OCI_CACHE_HOST"
export DISTRO="$1"
export VERSION="$(date -u +%Y%m%d%H%M%S).0.0-$(echo $DRONE_COMMIT_SHA|head -c8)-$DRONE_BUILD_NUMBER"
export TAG="$(cat BRANCH | tr '/' '_' | tr '\n' ' ')"
export CACHE="$OCI_CACHE_HOST/$OCI_NAME"
export IMAGE="$OCI_HOST/$OCI_NAME:$TAG"
#export IMAGE="$OCI_$OCI_NAME:$VERSION-$DISTRO"
printf "Name: $OCI_NAME\nImage: $IMAGE\n"
export PARAMS="--layers --cache-from=$CACHE --cache-to=$CACHE --network=host --cache-from=$OCI_NAME -f Dockerfile"
buildah build $PARAMS -t "$IMAGE" .
buildah push "$IMAGE"
export BUILD_COLOR_VARIANT="direct"
export VARIANT="$IMAGE-all-$BUILD_COLOR_VARIANT"
export PEERS="$(cd src && deno run --allow-env=BUILD_COLOR_VARIANT --allow-read=peers.json peers.js)"
[[ -z "$PEERS" ]] && echo "No persistent peers could be provided for $BUILD_COLOR_VARIANT" && exit 1
echo "Building $VARIANT with persistent peers $PEERS"
buildah build $PARAMS -t "$VARIANT" --build-arg "PEERS=$PEERS" .
buildah push "$VARIANT"
export BUILD_COLOR_VARIANT="green"
export VARIANT="$IMAGE-all-$BUILD_COLOR_VARIANT"
export PEERS="$(cd src && deno run --allow-env=BUILD_COLOR_VARIANT --allow-read=peers.json peers.js)"
[[ -z "$PEERS" ]] && echo "No persistent peers could be provided for $BUILD_COLOR_VARIANT" && exit 1
echo "Building $VARIANT with persistent peers $PEERS"
buildah build $PARAMS -t "$VARIANT" --build-arg "PEERS=$PEERS" .
buildah push "$VARIANT"
export BUILD_COLOR_VARIANT="blue"
export VARIANT="$IMAGE-all-$BUILD_COLOR_VARIANT"
export PEERS="$(cd src && deno run --allow-env=BUILD_COLOR_VARIANT --allow-read=peers.json peers.js)"
[[ -z "$PEERS" ]] && echo "No persistent peers could be provided for $BUILD_COLOR_VARIANT" && exit 1
echo "Building $VARIANT with persistent peers $PEERS"
buildah build $PARAMS -t "$VARIANT" --build-arg "PEERS=$PEERS" .
buildah push "$VARIANT"