Skip to content

Commit 185c727

Browse files
committed
Configures devcontainer for function development in codespaces
Sets up the devcontainer for efficient Azure Functions development by: - Adds Azurite for local storage emulation. - Exposes necessary ports (7071, 10000, 10001, 10002). - Installs Azure Functions Core Tools v4 via npm. - Includes Azure Developer CLI (azd). - Incorporates Mechanical-Markdown for documentation validation. - Installs Powershell 7.x This streamlines the development process and provides a consistent environment.
1 parent 94e337b commit 185c727

2 files changed

Lines changed: 42 additions & 28 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,33 @@
1+
# Snippy Functions – Dev Container image
12
FROM mcr.microsoft.com/vscode/devcontainers/universal:latest
23

3-
# Copy custom first notice message.
4+
# ──────────────────────────────────────────────────────────────
5+
# 1 – First‑run welcome notice
46
COPY first-run-notice.txt /tmp/staging/
5-
RUN sudo mv -f /tmp/staging/first-run-notice.txt /usr/local/etc/vscode-dev-containers/ \
7+
RUN sudo mv -f /tmp/staging/first-run-notice.txt \
8+
/usr/local/etc/vscode-dev-containers/ \
69
&& sudo rm -rf /tmp/staging
710

8-
# Install PowerShell 7.x
11+
# ──────────────────────────────────────────────────────────────
12+
# 2 – PowerShell 7.x
913
RUN sudo apt-get update \
10-
&& sudo apt-get install -y wget apt-transport-https software-properties-common \
11-
&& wget -q https://packages.microsoft.com/config/ubuntu/$(. /etc/os-release && echo $VERSION_ID)/packages-microsoft-prod.deb \
12-
&& sudo dpkg -i packages-microsoft-prod.deb \
13-
&& sudo apt-get update \
14-
&& sudo apt-get install -y powershell
14+
&& sudo apt-get install -y wget apt-transport-https software-properties-common \
15+
&& wget -q https://packages.microsoft.com/config/ubuntu/$(. /etc/os-release && echo $VERSION_ID)/packages-microsoft-prod.deb \
16+
&& sudo dpkg -i packages-microsoft-prod.deb \
17+
&& sudo apt-get update \
18+
&& sudo apt-get install -y powershell \
19+
&& sudo apt-get clean \
20+
&& rm -rf /var/lib/apt/lists/*
1521

16-
# Install Azure Functions Core Tools
17-
RUN curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg \
18-
&& sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg \
19-
&& sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-$(lsb_release -cs)-prod $(lsb_release -cs) main" > /etc/apt/sources.list.d/dotnetdev.list' \
20-
&& sudo apt-get update \
21-
&& sudo apt-get install -y azure-functions-core-tools-4
22+
# ──────────────────────────────────────────────────────────────
23+
# 3 – Azure Functions Core Tools v4
24+
# Using npm ensures the latest build and works on any distro.
25+
RUN npm install -g azure-functions-core-tools@4 --unsafe-perm
2226

23-
# Install Azure Developer CLI
27+
# ──────────────────────────────────────────────────────────────
28+
# 4 – Azure Developer CLI
2429
RUN curl -fsSL https://aka.ms/install-azd.sh | bash
2530

26-
# Install mechanical-markdown for quickstart validations
27-
RUN pip install mechanical-markdown
31+
# ──────────────────────────────────────────────────────────────
32+
# 5 – Mechanical‑Markdown (quick‑start doc validation)
33+
RUN pip install --no-cache-dir mechanical-markdown

.devcontainer/devcontainer.json

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,46 @@
11
{
22
"name": "Snippy Functions Codespace",
33
"dockerFile": "Dockerfile",
4+
5+
// ── Features ────────────────────────────────────────────────────────────
46
"features": {
57
"ghcr.io/devcontainers/features/azure-cli:1": {},
68
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {},
7-
"ghcr.io/devcontainers/features/node:1": {
8-
"version": "lts"
9-
}
9+
"ghcr.io/devcontainers/features/node:1": { "version": "lts" },
10+
11+
// Starts Azurite (blob/queue/table) automatically on container boot
12+
"ghcr.io/devcontainers/features/azurite:1": {}
1013
},
11-
"forwardPorts": [
12-
7071
13-
],
14+
15+
// ── Port forwards ───────────────────────────────────────────────────────
16+
"forwardPorts": [7071, 10000, 10001, 10002],
17+
18+
// ── Lifecycle commands ──────────────────────────────────────────────────
1419
"postCreateCommand": "./.devcontainer/setup.sh",
15-
"postStartCommand": "bash .devcontainer/start.sh",
20+
"postStartCommand": "bash .devcontainer/start.sh",
21+
22+
// ── VS Code customisation ───────────────────────────────────────────────
1623
"customizations": {
1724
"vscode": {
1825
"extensions": [
1926
"ms-azuretools.vscode-azurefunctions",
2027
"ms-azuretools.vscode-docker",
2128
"GitHub.copilot",
22-
"Azurite.azurite"
29+
"Azurite.azurite" // UI & table explorer
2330
]
2431
}
2532
},
33+
34+
// ── Misc ────────────────────────────────────────────────────────────────
2635
"mounts": [
2736
"source=codespaces-linux-var-lib-docker,target=/var/lib/docker,type=volume"
2837
],
2938
"overrideCommand": false,
3039
"remoteUser": "codespace",
3140
"runArgs": [
3241
"--cap-add=SYS_PTRACE",
33-
"--security-opt",
34-
"seccomp=unconfined",
42+
"--security-opt", "seccomp=unconfined",
3543
"--init",
3644
"--privileged"
3745
]
38-
}
46+
}

0 commit comments

Comments
 (0)