Compare commits
3 Commits
c078feceac
...
c83a4f115a
| Author | SHA1 | Date | |
|---|---|---|---|
| c83a4f115a | |||
| ca8160568b | |||
| 1d66fc2edc |
16
Dockerfile
16
Dockerfile
@@ -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 apt-get update && apt-get install -y azure-cli
|
||||
|
||||
# Configure Bash
|
||||
RUN cat <<'EOF' >> /etc/bash.bashrc
|
||||
# Add more packages (keep it last to optimize layer caching)
|
||||
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
|
||||
if [ -f /usr/lib/git-core/git-sh-prompt ]; then
|
||||
source /usr/lib/git-core/git-sh-prompt
|
||||
@@ -32,9 +35,12 @@ fi
|
||||
export PATH=$HOME/bin:$PATH
|
||||
EOF
|
||||
|
||||
# Add more packages (keep it last to optimize layer caching)
|
||||
RUN apt-get install -y zip unzip tree wget nano neovim \
|
||||
python3 python3-venv python3-pip
|
||||
RUN cat <<'EOF' >> /etc/skel/.bashrc
|
||||
|
||||
if ! command -v __git_ps1 > /dev/null; then
|
||||
source /etc/profile.d/git-prompt-helper
|
||||
fi
|
||||
EOF
|
||||
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
||||
25
azure-cli
25
azure-cli
@@ -67,15 +67,12 @@ if [ -z "$VOLUME_NAME" ]; then
|
||||
fi
|
||||
|
||||
# Find container runtime
|
||||
if command -v podman &> /dev/null; then
|
||||
CMD="podman"
|
||||
EXTRA_ARGS+=("--hostname $(hostname -s)")
|
||||
if command -v container &> /dev/null; then
|
||||
# Apple container command line tool
|
||||
CMD="container"
|
||||
elif command -v docker &> /dev/null; then
|
||||
CMD="docker"
|
||||
EXTRA_ARGS+=("--hostname $(hostname -s)")
|
||||
elif command -v container &> /dev/null; then
|
||||
# Apple container command line tool
|
||||
CMD="container"
|
||||
else
|
||||
echo "Error: No usable container runtime was found." >&2
|
||||
exit 1
|
||||
@@ -83,13 +80,25 @@ fi
|
||||
|
||||
if [ -n "$LIST" ]; then
|
||||
echo "Available accounts:"
|
||||
$CMD volume ls --format json | jq -r '.[] | select(.labels | has("account")) | .labels.account'
|
||||
# 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'
|
||||
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
|
||||
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
|
||||
# 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."
|
||||
read -p "Would you like to create one? (y/n) " -r RESPONSE
|
||||
if [[ ! "$RESPONSE" =~ ^[Yy]$ ]]; then
|
||||
|
||||
Reference in New Issue
Block a user