From 576596f9c95a1fe72786e7ee08719cb678fed762 Mon Sep 17 00:00:00 2001 From: SteveCInVA Date: Mon, 9 Feb 2026 16:41:14 +0000 Subject: [PATCH] Add Dockerfile and update devcontainer configuration for Python environment setup --- .devcontainer/Dockerfile | 3 +++ .devcontainer/devcontainer.json | 20 ++++++++++++++------ deployers/azure.yaml | 5 +++-- deployers/bicep/README.md | 2 ++ 4 files changed, 22 insertions(+), 8 deletions(-) create mode 100644 .devcontainer/Dockerfile diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000..841c429f --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,3 @@ +FROM mcr.microsoft.com/devcontainers/base:ubuntu +# Install the xz-utils package +RUN apt-get update && apt-get install -y xz-utils \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 9ebace40..bf3f4cd0 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -3,7 +3,14 @@ { "name": "Python 3", // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile - "image": "mcr.microsoft.com/devcontainers/python:0-3.11", + //"image": "mcr.microsoft.com/devcontainers/python:0-3.11", + "build": { + "dockerfile": "Dockerfile", + "args": { + "VARIANT": "3.11" + } + }, + // Features to add to the dev container. More info: https://containers.dev/features. "features": { "ghcr.io/devcontainers/features/docker-in-docker:2": { "version": "latest" @@ -14,18 +21,16 @@ "installBicep": true, "installUsingPython": true, "version": "2.72.0", - "bicepVersion": "latest" + "bicepVersion": "latest" }, "ghcr.io/devcontainers/features/terraform:1": {}, "ghcr.io/devcontainers/features/powershell:1": {}, "ghcr.io/azure/azure-dev/azd:latest": {} }, - // Features to add to the dev container. More info: https://containers.dev/features. - // "features": {}, // Use 'forwardPorts' to make a list of ports inside the container available locally. // "forwardPorts": [], // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "pip3 install --user -r application/single_app/requirements.txt", + "postCreateCommand": "python3 -m venv .venv && .venv/bin/pip install -r application/single_app/requirements.txt", // Configure tool-specific properties. "customizations": { "vscode": { @@ -36,7 +41,10 @@ "ms-vscode.azurecli", "HashiCorp.terraform", "ms-vscode.powershell" - ] + ], + "settings": { + "python.defaultInterpreterPath": "${containerWorkspaceFolder}/.venv/bin/python" + } } } // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. diff --git a/deployers/azure.yaml b/deployers/azure.yaml index 4ab51aa9..1ce818e5 100644 --- a/deployers/azure.yaml +++ b/deployers/azure.yaml @@ -62,7 +62,8 @@ hooks: echo "" echo "[2/4] Installing Python dependencies..." - if python3 -m pip install --user -r ./bicep/requirements.txt > /dev/null 2>&1; then + + if python3 -m venv .venv && .venv/bin/pip install -r ./bicep/requirements.txt > /dev/null 2>&1; then echo "✓ Dependencies installed successfully" else echo "✗ ERROR: Failed to install Python dependencies" >&2 @@ -71,7 +72,7 @@ hooks: echo "" echo "[3/4] Running post-deployment configuration..." - if python3 ./bicep/postconfig.py; then + if .venv/bin/python3 ./bicep/postconfig.py; then echo "✓ Post-deployment configuration completed" else echo "✗ ERROR: Post-deployment configuration failed" >&2 diff --git a/deployers/bicep/README.md b/deployers/bicep/README.md index 0cf883af..5c50ed9f 100644 --- a/deployers/bicep/README.md +++ b/deployers/bicep/README.md @@ -121,6 +121,8 @@ Using the bash terminal in Visual Studio Code `azd config set cloud.name AzureCloud` - If you work with other Azure clouds, you may need to update your cloud like `azd config set cloud.name AzureUSGovernment` - more information here - [Use Azure Developer CLI in sovereign clouds | Microsoft Learn](https://learn.microsoft.com/en-us/azure/developer/azure-developer-cli/sovereign-clouds) +`az login` - this will open a browser window shta the user with Owner level permissions to the target subscription will need to authenticate with. + `azd auth login` - this will open a browser window that the user with Owner level permissions to the target subscription will need to authenticate with. `azd env new ` - Use the same value for the \ that was used in the application registration.