Skip to content

Commit 41aa751

Browse files
committed
Update devcontainer to latest format.
Add support for .NET 7.0.
1 parent 004ec9e commit 41aa751

File tree

6 files changed

+63
-532
lines changed

6 files changed

+63
-532
lines changed

.devcontainer/Dockerfile

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,8 @@
1-
ARG VARIANT="5.0"
2-
FROM mcr.microsoft.com/dotnet/sdk:${VARIANT}-focal
1+
ARG VARIANT=6.0-focal
2+
FROM mcr.microsoft.com/dotnet/sdk:${VARIANT}
33

4-
# [Option] Install zsh
5-
ARG INSTALL_ZSH="true"
6-
# [Option] Upgrade OS packages to their latest versions
7-
ARG UPGRADE_PACKAGES="true"
4+
RUN wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb \
5+
&& dpkg -i packages-microsoft-prod.deb \
6+
&& rm packages-microsoft-prod.deb
87

9-
# Install needed packages and setup non-root user. Use a separate RUN statement to add your own dependencies.
10-
ARG USERNAME=vscode
11-
ARG USER_UID=1000
12-
ARG USER_GID=$USER_UID
13-
COPY library-scripts/common-debian.sh /tmp/library-scripts/
14-
RUN bash /tmp/library-scripts/common-debian.sh "${INSTALL_ZSH}" "${USERNAME}" "${USER_UID}" "${USER_GID}" "${UPGRADE_PACKAGES}" \
15-
&& apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts
16-
17-
# [Option] Install Node.js
18-
ARG INSTALL_NODE="false"
19-
ARG NODE_VERSION="none"
20-
ENV NVM_DIR=/usr/local/share/nvm
21-
ENV NVM_SYMLINK_CURRENT=true \
22-
PATH=${NVM_DIR}/current/bin:${PATH}
23-
COPY library-scripts/node-debian.sh /tmp/library-scripts/
24-
RUN if [ "$INSTALL_NODE" = "true" ]; then bash /tmp/library-scripts/node-debian.sh "${NVM_DIR}" "${NODE_VERSION}" "${USERNAME}"; fi \
25-
&& apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts
26-
27-
# [Option] Install Azure CLI
28-
ARG INSTALL_AZURE_CLI="false"
29-
COPY library-scripts/azcli-debian.sh /tmp/library-scripts/
30-
RUN if [ "$INSTALL_AZURE_CLI" = "true" ]; then bash /tmp/library-scripts/azcli-debian.sh; fi \
31-
&& apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts
8+
RUN apt-get update && apt-get install -y dotnet-sdk-7.0

.devcontainer/devcontainer.json

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,29 @@
11
{
2-
"name": "C# (.NET 5.0)",
3-
"build": {
4-
"dockerfile": "Dockerfile",
5-
"args": {
6-
// Update 'VARIANT' to pick a .NET version: 5.0
7-
"VARIANT": "5.0",
8-
// Options
9-
"INSTALL_NODE": "false",
10-
"NODE_VERSION": "lts/*",
11-
"INSTALL_AZURE_CLI": "false"
12-
}
13-
},
2+
"name": "C#",
3+
"dockerComposeFile": "docker-compose.yml",
4+
"service": "app",
5+
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
146

15-
// Set *default* container specific settings.json values on container create.
16-
"settings": {
17-
"terminal.integrated.shell.linux": "/bin/bash"
18-
},
7+
// Features to add to the dev container. More info: https://containers.dev/implementors/features.
8+
// "features": {},
199

20-
// Add the IDs of extensions you want installed when the container is created.
21-
"extensions": [
22-
"ms-dotnettools.csharp"
23-
],
10+
// Configure tool-specific properties.
11+
"customizations": {
12+
// Configure properties specific to VS Code.
13+
"vscode": {
14+
// Add the IDs of extensions you want installed when the container is created.
15+
"extensions": [
16+
"ms-dotnettools.csharp"
17+
]
18+
}
19+
},
2420

25-
// Use 'postCreateCommand' to run commands after the container is created.
26-
"postCreateCommand": "dotnet restore",
21+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
22+
// "forwardPorts": [3306],
2723

28-
// Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root.
29-
// "remoteUser": "vscode"
30-
}
24+
// Use 'postCreateCommand' to run commands after the container is created.
25+
"postCreateCommand": "dotnet restore"
26+
27+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
28+
// "remoteUser": "root"
29+
}

.devcontainer/docker-compose.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
services:
2+
app:
3+
build:
4+
context: .
5+
dockerfile: Dockerfile
6+
7+
volumes:
8+
- ../..:/workspaces:cached
9+
10+
# Overrides default command so things don't shut down after the process ends.
11+
command: sleep infinity
12+
13+
# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
14+
network_mode: service:db
15+
16+
# Uncomment the next line to use a non-root user for all processes.
17+
# user: vscode
18+
19+
# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
20+
# (Adding the "ports" property to this file will not forward from a Codespace.)
21+
22+
db:
23+
image: mysql:8.0
24+
restart: unless-stopped
25+
volumes:
26+
- mysql-data:/var/lib/mysql
27+
environment:
28+
MYSQL_ROOT_PASSWORD: pass
29+
MYSQL_DATABASE: mysqltest
30+
entrypoint: docker-entrypoint.sh --max-allowed-packet=96M --character-set-server=utf8mb4 --log-bin-trust-function-creators=1 --local-infile=1 --max-connections=250 --default-authentication-plugin=mysql_native_password
31+
32+
volumes:
33+
mysql-data:

.devcontainer/library-scripts/azcli-debian.sh

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)