-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·59 lines (47 loc) · 1.31 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
52
53
54
55
56
57
58
59
#!/bin/bash
print_usage() {
printf "\nBuild script usage: -p phpVer -n nodeJSVer\n\nIf no version is provided the latest will be used\n\n# For list of tags vsist https://mcr.microsoft.com/v2/vscode/devcontainers/php/tags/list\n\n"
}
while getopts p:s:n: flag;
do
case "${flag}" in
p) PHP=${OPTARG};;
n) NODE=${OPTARG};;
*) print_usage
exit 1 ;;
esac
done
if [ -z "$PHP" ]
then
# PHP=("7" "8.0" "8.1")
PHP=("8.1" "8.2")
printf "- No PHP version setting defaulting to 7 and 8 \n\n"
fi;
if [ -z "$NODE" ]
then
# NODE="--lts"
NODE="node"
printf "- No Node.js version provided setting NodeJs to latest version\n\n"
fi;
timestamp=$(date +'%Y%m%d')
printf "\n\ntimeStamp > $timestamp \n\n"
TARGETARCH=$(uname -m)
if [ "$TARGETARCH" = "x86_64" ]; then
TARGETARCH="amd64"
else
TARGETARCH="arm64"
fi
for phpver in ${PHP[@]}
do
printf "\nBuilding image with \n - PHP $phpver with Node $NODE for $TARGETARCH \n\n"
tag=$phpver
docker build \
--build-arg VARIANT="$phpver" \
--build-arg NODE_VERSION="$NODE" \
--build-arg CREATE_DATE="$timestamp" \
--build-arg TARGETARCH=$TARGETARCH \
--no-cache \
-t local/drupal-devcontainer:"$tag"-$NODE \
-t local/drupal-devcontainer:latest .
printf "\n\nSuccessfully built base image with tag $tag\n\n"
done