Skip to content

Commit 681c7e9

Browse files
committed
Remove sensitive ARGs from Dockerfile to fix security warnings
- Removed AZURE_KEY and AZURE_KEY_TYPE build-time ARGs - Azure configuration now only done at runtime via environment variables - Fixes Docker BuildKit security warnings about sensitive data in ARGs
1 parent 6e4c7fb commit 681c7e9

File tree

1 file changed

+5
-64
lines changed

1 file changed

+5
-64
lines changed

test/azure/Dockerfile

Lines changed: 5 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -19,53 +19,12 @@ ARG PGBR_BRANCH="azure-managed-identities"
1919
# ============================================================================
2020
# Azure Blob Storage Configuration (Optional)
2121
# ============================================================================
22-
# This Dockerfile supports three deployment scenarios:
22+
# Azure configuration is done at runtime via environment variables for security.
23+
# See DOCKER_README.md for usage examples and authentication methods.
2324
#
24-
# SCENARIO 1: Local Backups Only (Mac/Linux/Windows)
25-
# - No Azure configuration needed
26-
# - Backups stored locally in /var/lib/pgbackrest (repo1)
27-
# Usage:
28-
# docker run -e POSTGRES_PASSWORD=secret <image-name>
29-
#
30-
# SCENARIO 2: Azure Blob Storage from Local System (Mac/Linux/Windows)
31-
# - Use SAS Token or Shared Key authentication
32-
# - Backups stored in both local (repo1) and Azure (repo2)
33-
# Usage with SAS Token (recommended):
34-
# docker run -e POSTGRES_PASSWORD=secret \
35-
# -e AZURE_ACCOUNT=<your-storage-account> \
36-
# -e AZURE_CONTAINER=<your-container> \
37-
# -e AZURE_KEY="<sas-token>" \
38-
# -e AZURE_KEY_TYPE=sas \
39-
# <image-name>
40-
# Usage with Shared Key:
41-
# docker run -e POSTGRES_PASSWORD=secret \
42-
# -e AZURE_ACCOUNT=<your-storage-account> \
43-
# -e AZURE_CONTAINER=<your-container> \
44-
# -e AZURE_KEY=<base64-encoded-key> \
45-
# -e AZURE_KEY_TYPE=shared \
46-
# <image-name>
47-
#
48-
# SCENARIO 3: Azure Managed Identity (Azure VMs/Container Instances/AKS)
49-
# - No keys needed - uses Azure Managed Identity
50-
# - Backups stored in both local (repo1) and Azure (repo2)
51-
# - Requires Managed Identity enabled on Azure resource
52-
# Usage:
53-
# docker run -e POSTGRES_PASSWORD=secret \
54-
# -e AZURE_ACCOUNT=<your-storage-account> \
55-
# -e AZURE_CONTAINER=<your-container> \
56-
# -e AZURE_KEY_TYPE=auto \
57-
# <image-name>
58-
#
59-
# Azure key types:
60-
# - "auto" (Managed Identity) - Only works on Azure VMs/ACI/AKS, no key needed
61-
# - "shared" (Shared Key) - Works anywhere, requires base64-encoded storage account key
62-
# - "sas" (SAS Token) - Works anywhere, requires SAS token string
25+
# All Azure credentials (keys, tokens) should be provided at runtime, not build time.
26+
# No build-time ARGs for sensitive data to avoid security warnings.
6327
# ============================================================================
64-
ARG AZURE_ACCOUNT=""
65-
ARG AZURE_CONTAINER=""
66-
ARG AZURE_KEY=""
67-
ARG AZURE_KEY_TYPE="auto"
68-
ARG AZURE_REPO_PATH="/demo-repo"
6928

7029
USER root
7130

@@ -104,6 +63,7 @@ RUN mkdir -p /etc/pgbackrest /var/lib/pgbackrest /var/log/pgbackrest && \
10463
chown -R postgres:postgres /var/lib/pgbackrest /var/log/pgbackrest /etc/pgbackrest
10564

10665
# Create base config (without Azure)
66+
# Azure configuration is done at runtime via environment variables
10767
RUN printf '%s\n' \
10868
'[global]' \
10969
'repo1-path=/var/lib/pgbackrest' \
@@ -119,25 +79,6 @@ RUN printf '%s\n' \
11979
chown postgres:postgres /etc/pgbackrest/pgbackrest.conf && \
12080
chmod 660 /etc/pgbackrest/pgbackrest.conf
12181

122-
# Add Azure config if build args are provided
123-
# For auto (Managed Identity), only account and container are needed
124-
# For shared/sas, key is also required
125-
RUN if [ -n "$AZURE_ACCOUNT" ] && [ -n "$AZURE_CONTAINER" ]; then \
126-
if [ "$AZURE_KEY_TYPE" = "auto" ] || [ -n "$AZURE_KEY" ]; then \
127-
printf '\n%s\n' \
128-
'repo2-type=azure' \
129-
"repo2-azure-account=${AZURE_ACCOUNT}" \
130-
"repo2-azure-container=${AZURE_CONTAINER}" \
131-
"repo2-azure-key-type=${AZURE_KEY_TYPE}" \
132-
"repo2-path=${AZURE_REPO_PATH}" \
133-
'repo2-retention-full=4' \
134-
>> /etc/pgbackrest/pgbackrest.conf; \
135-
if [ "$AZURE_KEY_TYPE" != "auto" ] && [ -n "$AZURE_KEY" ]; then \
136-
echo "repo2-azure-key=${AZURE_KEY}" >> /etc/pgbackrest/pgbackrest.conf; \
137-
fi; \
138-
fi; \
139-
fi
140-
14182
# Create script to configure Azure at runtime via environment variables
14283
RUN cat > /usr/local/bin/configure-azure.sh <<'SCRIPT_EOF'
14384
#!/bin/bash

0 commit comments

Comments
 (0)