Skip to content

Commit 4de78ce

Browse files
author
Your Name
committed
add devcontainer
1 parent 3496035 commit 4de78ce

2 files changed

Lines changed: 86 additions & 0 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
ARG DOTNET_VERSION
2+
ARG MAINTAINER
3+
ARG TZ
4+
FROM mcr.microsoft.com/dotnet/sdk:${DOTNET_VERSION} AS dotnet-maui-android
5+
6+
LABEL maintainer=${MAINTAINER}
7+
ENV TZ=${TZ}
8+
ENV DOTNET_CLI_TELEMETRY_OPTOUT=1
9+
10+
# JAVA
11+
ARG JAVA_VERSION
12+
RUN <<EOF
13+
set -e
14+
apt-get update
15+
apt-get install -y openjdk-${JAVA_VERSION}-jdk-headless
16+
rm -rf /var/lib/apt/lists/*
17+
EOF
18+
19+
ENV JAVA_HOME=/usr/lib/jvm/java-${JAVA_VERSION}-openjdk-amd64/
20+
21+
# Android SDK Manager
22+
RUN <<EOF
23+
set -e
24+
echo "deb http://deb.debian.org/debian bullseye-backports main contrib" > /etc/apt/sources.list.d/bullseye-backports.list
25+
echo "deb-src http://deb.debian.org/debian bullseye-backports main contrib" >> /etc/apt/sources.list.d/bullseye-backports.list
26+
apt-get update
27+
apt-get install -t bullseye-backports -y sdkmanager
28+
rm -rf /var/lib/apt/lists/*
29+
EOF
30+
31+
ENV ANDROID_SDK_ROOT=/usr/lib/android-sdk
32+
33+
# Android toolchain
34+
ARG ANDROID_API
35+
ARG BUILD_TOOLS_VERSION
36+
RUN <<EOF
37+
set -e
38+
sdkmanager "platform-tools" "build-tools;${BUILD_TOOLS_VERSION}" "platforms;android-${ANDROID_API}"
39+
EOF
40+
41+
ARG MAUI_VERSION
42+
# MAUI (We can only install the latest version, the ARG is to cache bust if that version changed)
43+
RUN <<EOF
44+
set -e
45+
dotnet workload install maui-android
46+
EOF

.devcontainer/devcontainer.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/dotnet
3+
{
4+
"name": "C# (.NET)",
5+
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6+
// "image": "mcr.microsoft.com/devcontainers/dotnet:1-7.0-bookworm",
7+
"build": {
8+
"dockerfile": "Dockerfile",
9+
"context": "..",
10+
// Update 'VARIANT' to pick a dotnet version. Rebuild the container
11+
"args": {
12+
"TZ": "UTC",
13+
// "MAUI_VERSION": "7.0.101",
14+
"DOTNET_VERSION": "7.0",
15+
"JAVA_VERSION": "11",
16+
"ANDROID_API": "33",
17+
"BUILD_TOOLS_VERSION": "33.0.2"
18+
}
19+
}
20+
21+
// "features": {
22+
// "ghcr.io/nordcominc/devcontainer-features/android-sdk:1": {}
23+
// }
24+
25+
// Features to add to the dev container. More info: https://containers.dev/features.
26+
// "features": {},
27+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
28+
// "forwardPorts": [5000, 5001],
29+
// "portsAttributes": {
30+
// "5001": {
31+
// "protocol": "https"
32+
// }
33+
// }
34+
// Use 'postCreateCommand' to run commands after the container is created.
35+
// "postCreateCommand": "dotnet restore",
36+
// Configure tool-specific properties.
37+
// "customizations": {},
38+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
39+
// "remoteUser": "root"
40+
}

0 commit comments

Comments
 (0)