Compare commits

..

3 Commits

Author SHA1 Message Date
c83a4f115a Fix: adopted volume list parsing for docker CLI.
All checks were successful
Build Docker Image / build (push) Successful in 11s
2025-12-17 07:59:19 +01:00
ca8160568b Fix: Corrected Git Prompt activation. 2025-12-17 07:58:45 +01:00
1d66fc2edc Remove unverified support for podman. 2025-12-16 10:14:48 +01:00
2 changed files with 28 additions and 13 deletions

View File

@@ -18,9 +18,12 @@ RUN curl -sL -o /tmp/packages-microsoft-prod.deb https://packages.microsoft.com/
RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/microsoft-prod.gpg] https://packages.microsoft.com/repos/azure-cli/ noble main" > /etc/apt/sources.list.d/azure-cli.list RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/microsoft-prod.gpg] https://packages.microsoft.com/repos/azure-cli/ noble main" > /etc/apt/sources.list.d/azure-cli.list
RUN apt-get update && apt-get install -y azure-cli RUN apt-get update && apt-get install -y azure-cli
# Configure Bash # Add more packages (keep it last to optimize layer caching)
RUN cat <<'EOF' >> /etc/bash.bashrc RUN apt-get install -y zip unzip tree wget nano neovim \
python3 python3-venv python3-pip
# Configure Bash
RUN cat <<'EOF' >> /etc/profile.d/git-prompt-helper
# Include Git prompt helpers if available # Include Git prompt helpers if available
if [ -f /usr/lib/git-core/git-sh-prompt ]; then if [ -f /usr/lib/git-core/git-sh-prompt ]; then
source /usr/lib/git-core/git-sh-prompt source /usr/lib/git-core/git-sh-prompt
@@ -32,9 +35,12 @@ fi
export PATH=$HOME/bin:$PATH export PATH=$HOME/bin:$PATH
EOF EOF
# Add more packages (keep it last to optimize layer caching) RUN cat <<'EOF' >> /etc/skel/.bashrc
RUN apt-get install -y zip unzip tree wget nano neovim \
python3 python3-venv python3-pip if ! command -v __git_ps1 > /dev/null; then
source /etc/profile.d/git-prompt-helper
fi
EOF
COPY entrypoint.sh /entrypoint.sh COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh RUN chmod +x /entrypoint.sh

View File

@@ -67,15 +67,12 @@ if [ -z "$VOLUME_NAME" ]; then
fi fi
# Find container runtime # Find container runtime
if command -v podman &> /dev/null; then if command -v container &> /dev/null; then
CMD="podman" # Apple container command line tool
EXTRA_ARGS+=("--hostname $(hostname -s)") CMD="container"
elif command -v docker &> /dev/null; then elif command -v docker &> /dev/null; then
CMD="docker" CMD="docker"
EXTRA_ARGS+=("--hostname $(hostname -s)") EXTRA_ARGS+=("--hostname $(hostname -s)")
elif command -v container &> /dev/null; then
# Apple container command line tool
CMD="container"
else else
echo "Error: No usable container runtime was found." >&2 echo "Error: No usable container runtime was found." >&2
exit 1 exit 1
@@ -83,13 +80,25 @@ fi
if [ -n "$LIST" ]; then if [ -n "$LIST" ]; then
echo "Available accounts:" echo "Available accounts:"
# Unfortunately 'container' and 'docker' CLIs are not compatible
if [ "container" = "$CMD" ]; then
$CMD volume ls --format json | jq -r '.[] | select(.labels | has("account")) | .labels.account' $CMD volume ls --format json | jq -r '.[] | select(.labels | has("account")) | .labels.account'
else
# Docker has settled to provide labels as one string, that's inconvinient
$CMD volume ls --format=json | jq -sr '.[] | .Account = (.Labels | match("account=([a-zA-Z0-9._%@+-]+)"; "x") | .captures[0].string) | .Account'
fi
exit 0 exit 0
fi fi
if [ "container" = "$CMD" ]; then
_FOUND="$($CMD volume ls --format json | jq -r --arg name "$VOLUME_NAME" --arg account "$ACCOUNT_NAME" '.[] | select(.name == $name or .labels.account == $account) | "FOUND"')"
else
_FOUND="$($CMD volume ls --format=json | jq -sr --arg name "$VOLUME_NAME" --arg account "$ACCOUNT_NAME" '.[] | .Account = (.Labels | match("account=([a-zA-Z0-9._%@+-]+)"; "x") // {} | .captures[0].string) | select(.Name == $name or .Account == $account) | "FOUND"')"
fi
# Check, if the account volume exists, if not create it # Check, if the account volume exists, if not create it
# This ensures persistent storage for the Azure CLI configuration # This ensures persistent storage for the Azure CLI configuration
if [ ! "FOUND" = "$($CMD volume ls --format json | jq -r --arg name "$VOLUME_NAME" --arg account "$ACCOUNT_NAME" '.[] | select(.name == $name or .labels.account == $account) | "FOUND"')" ]; then if [ ! "FOUND" = "$_FOUND" ]; then
echo "A volume for account '$ACCOUNT_NAME' does not exist." echo "A volume for account '$ACCOUNT_NAME' does not exist."
read -p "Would you like to create one? (y/n) " -r RESPONSE read -p "Would you like to create one? (y/n) " -r RESPONSE
if [[ ! "$RESPONSE" =~ ^[Yy]$ ]]; then if [[ ! "$RESPONSE" =~ ^[Yy]$ ]]; then