-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·51 lines (44 loc) · 1.55 KB
/
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
#!/usr/bin/env bash
set -e
#Input parametes
BUILD_ARCH=$1
BUILD_SERVERS=$2
#Build arguments
S6_OVERLAY_VERSION=$(curl -sX GET "https://api.github.com/repos/just-containers/s6-overlay/releases/latest" |
awk '/tag_name/{print $4;exit}' FS='[""]' | awk '{print substr($1,2); }')
ANSIBLE_CORE_VERSION="2.16.2"
COREDNS_VERSION=$(curl -sX GET "https://api.github.com/repos/coredns/coredns/releases/latest" |
awk '/tag_name/{print $4;exit}' FS='[""]' | awk '{print substr($1,2); }')
XSERVER_DIRS=("baseimage-ubuntu" "openvpn-as" "wireguard")
XSERVER_REGISTRY="localhost"
#shellcheck disable=SC2034
declare -A XSERVER_IMG
XSERVER_IMG["baseimage-ubuntu"]="xs-baseimage-ubuntu:22.04"
XSERVER_IMG["openvpn-as"]="xs-openvpn-as:latest"
XSERVER_IMG["wireguard"]="xs-wireguard:latest"
XSERVER_IMG["."]="xs-ansible-core:latest"
if [ "$BUILD_ARCH" == "arm64" ]; then
TARGET_ARCH="arm64"
S6_OVERLAY_ARCH="aarch64"
elif [ "$BUILD_ARCH" == "amd64" ]; then
TARGET_ARCH="amd64"
S6_OVERLAY_ARCH="x86_64"
else
echo "Invalid Arch value $BUILD_ARCH"
exit 1
fi
if [ -z "${BUILD_SERVERS}" ]; then
BUILD_SERVERS="${XSERVER_DIRS[*]}"
fi
#Create images
for server in ${BUILD_SERVERS}; do
podman build --arch="${TARGET_ARCH}" \
--build-arg S6_OVERLAY_ARCH="${S6_OVERLAY_ARCH}" \
--build-arg S6_OVERLAY_VERSION="${S6_OVERLAY_VERSION}" \
--build-arg ARCH="${TARGET_ARCH}" \
--build-arg ANSIBLE_CORE_VERSION="${ANSIBLE_CORE_VERSION}" \
--build-arg COREDNS_VERSION="${COREDNS_VERSION}" \
-t "${XSERVER_REGISTRY}"/"${XSERVER_IMG[$server]}" \
-f "$server"/Containerfile \
"$server"/.
done