File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,31 +5,35 @@ set -euo pipefail
55# CloudControl build script
66# Usage:
77#
8- # bash build.sh <tag> [<flavour>]
8+ # bash build.sh [ <tag> [<flavour>] ]
99#
10+ # If no tag is given, latest will be used
11+ # The flavour can only be specified, if a tag is given.
1012# If no flavour is specified, all flavours will be built
1113
1214mv Dockerfile Dockerfile.sav & > /dev/null || true
1315
14- TAG=latest
15- if [ -n " $1 " ]
16+ TAG=" ${1-latest} "
17+ EXISTING_FLAVOURS=$( find flavour -mindepth 1 -maxdepth 1 -type d -exec basename {} \; | paste -s -d ' ' -) " "
18+ FLAVOURS=' '
19+ if [[ $# -ne 2 ]]
1620then
17- TAG=$1
18- fi
19-
20- FLAVOURS=" "
21- if [ -n " $1 " ] && [ -z " $2 " ] || [ -z " $1 " ]
22- then
23- FLAVOURS=$( find flavour -maxdepth 1 -type d -exec basename {} \; | grep -v flavour | paste -s -d " " -)
21+ FLAVOURS=${EXISTING_FLAVOURS}
2422else
25- FLAVOURS=$2
23+ if [[ " ${EXISTING_FLAVOURS} " == * " $2 " * ]]
24+ then
25+ FLAVOURS=$2
26+ else
27+ >&2 echo " The flavour '$2 ' does not exist!"
28+ exit 1
29+ fi
2630fi
2731
2832for FLAVOUR in ${FLAVOURS}
2933do
3034 cat build/Dockerfile.prefix > Dockerfile
3135 cat " flavour/${FLAVOUR} /Dockerfile.flavour" >> Dockerfile
32- cat build/Dockerfile.suffix.mo | docker run --rm -i -e FLAVOUR=${FLAVOUR} -e BUILD_DATE=$( date -Iseconds) ghcr.io/tests-always-included/mo:3.0.5 >> Dockerfile
36+ cat build/Dockerfile.suffix.mo | docker run --rm -i -e FLAVOUR=${FLAVOUR} -e BUILD_DATE=" $( date -Iseconds) " ghcr.io/tests-always-included/mo:3.0.5 >> Dockerfile
3337 docker build --pull . --no-cache -t " ghcr.io/dodevops/cloudcontrol-${FLAVOUR} :${TAG} "
3438done
3539
Original file line number Diff line number Diff line change 33if [[ " ${FLAVOUR} " =~ (simple| tanzu| gcloud) ]]
44then
55 execHandle ' Installing fish' sudo apk add fish perl fzf git
6- elif [[ " ${FLAVOUR} " == " azure" ]]
7- then
8- prepare
9- execHandle ' Installing fish' sudo yum install -y fish perl git
10- execHandle ' Downloading fzf' curl -f -s -L https://github.com/junegunn/fzf/archive/master.zip -o master.zip
11- execHandle ' Unzipping fzf' unzip master.zip
12- execHandle ' Moving fzf' mv fzf-master ~ /bin
13- execHandle ' Installing fzf' ~ /bin/fzf-master/install --all
14- cleanup
15- elif [[ " ${FLAVOUR} " == " aws" ]]
6+ elif [[ " ${FLAVOUR} " =~ (aws| azure) ]]
167then
178 prepare
189 execHandle ' Downloading fish repo' sudo curl -f -s -L https://download.opensuse.org/repositories/shells:fish:release:3/CentOS_7/shells:fish:release:3.repo -o /etc/yum.repos.d/shells:fish:release:3.repo
Original file line number Diff line number Diff line change 1- FROM mcr.microsoft.com/azure-cli:cbl-mariner2 .0
1+ FROM mcr.microsoft.com/azure-cli:azurelinux3 .0
22
3- RUN yum install -y sudo curl tar unzip && \
4- echo "cloudcontrol ALL=(root)NOPASSWD:/usr/bin/yum *" > /etc/sudoers.d/cloudcontrol && \
5- echo "cloudcontrol ALL=(root)NOPASSWD:/usr/bin/az *" >> /etc/sudoers.d/cloudcontrol && \
6- echo "cloudcontrol ALL=(root)NOPASSWD:/usr/bin/chmod *" >> /etc/sudoers.d/cloudcontrol && \
7- echo "cloudcontrol ALL=(root)NOPASSWD:/usr/bin/cp *" >> /etc/sudoers.d/cloudcontrol && \
8- echo "cloudcontrol ALL=(root)NOPASSWD:/usr/bin/update-ca-trust" >> /etc/sudoers.d/cloudcontrol && \
9- adduser -mr cloudcontrol && \
10- mkdir /home/cloudcontrol/bin && \
3+
4+ RUN <<RUN_SCRIPT
5+ ln -s /usr/bin/tdnf yum
6+ ln -s /usr/bin/tdnf /usr/bin/yum
7+ tdnf install --assumeyes sudo curl tar unzip
8+ for TOOL in 'yum *' 'tdnf *' 'az *' 'chmod *' 'cp *' 'update-ca-trust' 'curl *'
9+ do
10+ echo "cloudcontrol ALL=(root)NOPASSWD:/usr/bin/${TOOL}" >> /etc/sudoers.d/cloudcontrol
11+ done
12+ adduser -mr cloudcontrol
13+ mkdir /home/cloudcontrol/bin
1114 chown cloudcontrol /home/cloudcontrol/bin
15+ RUN_SCRIPT
1216
1317# Flavour
14-
1518COPY flavour/azure/flavour /home/cloudcontrol/flavour
1619COPY flavour/azure/flavourinit.sh /home/cloudcontrol/bin/flavourinit.sh
1720RUN chmod +x /home/cloudcontrol/bin/flavourinit.sh
Original file line number Diff line number Diff line change @@ -7,10 +7,10 @@ description: |
77 (located in ~/bin, thus available without path) to re-execute the same login commands as the
88 initialization process does.
99configuration :
10- - " Environment AZ_SUBSCRIPTION: The Azure subscription to use in this container (deprecated)"
1110 - " Environment ARM_SUBSCRIPTION_ID: The Azure subscription to use in this container"
12- - " Environment AZ_TENANTID: The Azure tenant id to log into (optional, deprecated)"
1311 - " Environment ARM_TENANT_ID: The Azure tenant id to log into (optional)"
12+ - " Environment AZ_SUBSCRIPTION: The Azure subscription to use in this container (deprecated)"
13+ - " Environment AZ_TENANTID: The Azure tenant id to log into (optional, deprecated)"
1414 - " Environment AZ_USE_ARM_SPI: Uses the environment variables ARM_CLIENT_ID and ARM_CLIENT_SECRET for service principal auth [false]"
1515platforms :
1616 - linux/amd64
You can’t perform that action at this time.
0 commit comments