Skip to content

Commit fe6cff6

Browse files
committed
feat: migrate azure flavour to use azurelinux3.0 #184
1 parent c8347fc commit fe6cff6

4 files changed

Lines changed: 32 additions & 34 deletions

File tree

build.sh

100644100755
Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff 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

1214
mv 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 ]]
1620
then
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}
2422
else
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
2630
fi
2731

2832
for FLAVOUR in ${FLAVOURS}
2933
do
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}"
3438
done
3539

feature/_fish/install.sh

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,7 @@
33
if [[ "${FLAVOUR}" =~ (simple|tanzu|gcloud) ]]
44
then
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) ]]
167
then
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

flavour/azure/Dockerfile.flavour

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
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-
1518
COPY flavour/azure/flavour /home/cloudcontrol/flavour
1619
COPY flavour/azure/flavourinit.sh /home/cloudcontrol/bin/flavourinit.sh
1720
RUN chmod +x /home/cloudcontrol/bin/flavourinit.sh

flavour/azure/flavour.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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.
99
configuration:
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]"
1515
platforms:
1616
- linux/amd64

0 commit comments

Comments
 (0)