-
Notifications
You must be signed in to change notification settings - Fork 92
Add Dockerfile and update devcontainer configuration for Python envir… #704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: Development
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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" | ||
| } | ||
| }, | ||
|
Comment on lines
+7
to
+12
|
||
| // 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. | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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 | ||||||||||||||||||||||||||||||
|
Comment on lines
+66
to
69
|
||||||||||||||||||||||||||||||
| 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 | |
| if python3 -m venv .venv; then | |
| if pip_output=$(.venv/bin/pip install -r ./bicep/requirements.txt 2>&1); then | |
| echo "✓ Dependencies installed successfully" | |
| else | |
| echo "$pip_output" >&2 | |
| echo "✗ ERROR: Failed to install Python dependencies" >&2 | |
| exit 1 | |
| fi | |
| else | |
| echo "✗ ERROR: Failed to create Python virtual environment" >&2 |
Copilot
AI
Feb 10, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency/portability, prefer invoking the venv interpreter as .venv/bin/python (not python3). Some venvs only guarantee python exists, and your devcontainer config also points VS Code at .venv/bin/python.
| if .venv/bin/python3 ./bicep/postconfig.py; then | |
| if .venv/bin/python ./bicep/postconfig.py; then |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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. | ||||||
|
||||||
| `az login` - this will open a browser window shta the user with Owner level permissions to the target subscription will need to authenticate with. | |
| `az login` - opens a browser window where a user with Owner level permissions to the target subscription must authenticate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider cleaning up apt metadata to keep the devcontainer image smaller and more reproducible (e.g.,
--no-install-recommendsand removing/var/lib/apt/lists/*after install).