Skip to content

Commit

Permalink
updated devcontainer setup
Browse files Browse the repository at this point in the history
  • Loading branch information
LIO2MU committed Jun 11, 2024
1 parent f461cca commit 3028162
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 483 deletions.
53 changes: 29 additions & 24 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
# from: https://github.com/microsoft/vscode-dev-containers/blob/14b53bf68f467dc6fe1a1a378ba10b9db9e6d318/containers/dotnet/.devcontainer/Dockerfile
# and: https://github.com/microsoft/vscode-dev-containers/blob/main/containers/powershell/.devcontainer/Dockerfile
ARG VARIANT=8.0-bookworm-slim
FROM mcr.microsoft.com/dotnet/sdk:${VARIANT}
ENV PATH $PATH:/home/vscode/.dotnet:/home/vscode/.dotnet/tools

ARG DOTNET_VARIANT=6.0-bullseye
FROM mcr.microsoft.com/vscode/devcontainers/dotnet:0-${DOTNET_VARIANT}
# clear this environment variable so xml docs from NuGet packages are unpackaged. The default dotnet/sdk image sets it to 'skip'.
# see https://github.com/dotnet/dotnet-docker/issues/2790
ENV NUGET_XMLDOC_MODE=

ARG INSTALL_ZSH="true"
ARG UPGRADE_PACKAGES="true"
# Temporary: Upgrade packages due to mentioned CVEs
# They are installed by the base image (mcr.microsoft.com/dotnet/sdk) which does not have the patch.
# https://msrc.microsoft.com/update-guide/vulnerability/CVE-2024-0057
RUN if [ "$(dpkg --print-architecture)" = "amd64" ]; then \
apt-get update && \
apt-get install -y wget && \
POWERSHELL_FILE_NAME="powershell_7.4.1-1.deb_amd64.deb" && \
wget https://github.com/PowerShell/PowerShell/releases/download/v7.4.1/${POWERSHELL_FILE_NAME} && \
dpkg -i ${POWERSHELL_FILE_NAME} && \
apt-get install -f && \
rm ${POWERSHELL_FILE_NAME} ; \
fi

# Install needed packages and setup non-root user. Use a separate RUN statement to add your own dependencies.
ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID
COPY library-scripts/*.sh /tmp/library-scripts/
RUN apt-get update \
&& /bin/bash /tmp/library-scripts/common-debian.sh "${INSTALL_ZSH}" "${USERNAME}" "${USER_UID}" "${USER_GID}" "${UPGRADE_PACKAGES}" "true" "true" \
&& chsh "${USERNAME}" -s "$(which pwsh)" \
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts

# Download the latest stable `nuget.exe` to `/usr/local/bin`
RUN curl -o /usr/local/bin/nuget.exe https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
RUN chmod +x /usr/local/bin/nuget.exe


# [Optional] Uncomment this section to install additional packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>
RUN if [ "$(dpkg --print-architecture)" = "arm64" ]; then \
apt-get update && \
apt-get install -y curl tar && \
POWERSHELL_FILE_PATH="/opt/microsoft/powershell/7" && \
curl -L -o /tmp/powershell.tar.gz https://github.com/PowerShell/PowerShell/releases/download/v7.4.1/powershell-7.4.1-linux-arm64.tar.gz && \
mkdir -p ${POWERSHELL_FILE_PATH} && \
tar zxf /tmp/powershell.tar.gz -C ${POWERSHELL_FILE_PATH} && \
chmod +x ${POWERSHELL_FILE_PATH}/pwsh && \
ln -snf ${POWERSHELL_FILE_PATH}/pwsh /usr/bin/pwsh && \
rm /tmp/powershell.tar.gz ; \
fi
27 changes: 23 additions & 4 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
// https://github.com/devcontainers/images/tree/main/src/dotnet/.devcontainer
{
"name": "AtlassianPS Dev Environment",
"dockerFile": "Dockerfile",
"build": {
"dockerfile": "./Dockerfile",
"context": "."
},
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {
"installZsh": "true",
"username": "vscode",
"userUid": "1000",
"userGid": "1000",
"upgradePackages": "true"
},
"ghcr.io/devcontainers/features/node:1": {
"version": "none"
},
"ghcr.io/devcontainers/features/git:1": {
"version": "latest",
"ppa": "false"
}
},
"customizations": {
"vscode": {
"settings": {
Expand All @@ -23,6 +42,6 @@
]
}
},
"postCreateCommand": "pwsh -c './Tools/setup.ps1'",
"remoteUser": "vscode"
"remoteUser": "vscode",
"postCreateCommand": "pwsh -c './Tools/setup.ps1'"
}
Loading

0 comments on commit 3028162

Please sign in to comment.