visual-studio-code - 如何将 Pulumi 添加到我的 GitHub Codespaces / VSCode .NET devcontainer?
问题描述
我想从 VS Code使用Pulumi .NET / C#.devcontainer
开发和部署 IaC 。如何将此功能添加到环境中?
解决方案
我将https://github.com/pulumi/pulumi-docker-containers/blob/main/docker/dotnet/Dockerfile中的构建容器步骤包含在.devcontainer/Dockerfile
:
ARG DOTNET_VARIANT="3.1"
ARG PULUMI_VERSION=latest
ARG INSTALL_NODE="true"
ARG NODE_VERSION="lts/*"
# --------------------------------------------------------------------------------
FROM debian:11-slim AS builder
RUN apt-get update -y && \
apt-get upgrade -y && \
apt-get install -y \
curl \
build-essential \
git
RUN if [ "$PULUMI_VERSION" = "latest" ]; then \
curl -fsSL https://get.pulumi.com/ | bash; \
else \
curl -fsSL https://get.pulumi.com/ | bash -s -- --version $PULUMI_VERSION ; \
fi
# --------------------------------------------------------------------------------
FROM mcr.microsoft.com/vscode/devcontainers/dotnetcore:0-${DOTNET_VARIANT}
RUN if [ "${INSTALL_NODE}" = "true" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
COPY --from=builder /root/.pulumi/bin/pulumi /pulumi/bin/pulumi
COPY --from=builder /root/.pulumi/bin/*-dotnet* /pulumi/bin/
ENV PATH "/pulumi/bin:${PATH}"
我用这个控制这个过程.devcontainer/devcontainer.json
:
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.203.0/containers/alpine
{
"name": "C# (.NET)",
"build": {
"dockerfile": "Dockerfile",
"args": {
"DOTNET_VARIANT": "3.1",
"PULUMI_VERSION": "latest",
"INSTALL_NODE": "true",
"NODE_VERSION": "lts/*"
}
},
"features": {
"azure-cli": "latest"
},
// Set *default* container specific settings.json values on container create.
"settings": {},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-dotnettools.csharp"
],
// 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": "uname -a",
// Replace when using a ptrace-based debugger like C++, Go, and Rust
// "runArgs": [ "--init", "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ],
"runArgs": [
"--init"
],
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
请注意,重建将需要一段时间,一旦它表明.
GitHub Codespaces: Details
之后,pulumi login
例如pulumi new azure-csharp
应该在容器上工作。
推荐阅读
- mahapps.metro - MetroApps 未找到 ResourceDictionary 2.0.0-alpha0748
- reactjs - React 测试库的 waitFor() 返回 null
- c# - 如何处理在 C# 中加载时显示为串联字符串的 Crystal Report 记录选择公式?
- reactjs - 父元素的排队 React 更新是否也总是更新子元素?
- python - 使用 .loc 覆盖值
- angular - 使用变量 angular2 路由?
- python - 如何规范化 [0,1] 范围内的数据框中的数据?
- c# - MailKit 的 IMessageSummary.Envelope.InReplyTo 字段始终为空
- python - 使用 lxml 添加具有不同于根元素的命名空间的 xml 子元素
- database-replication - 数据库复制失败并出现“进程无法执行'sp_MSadd_replcmds'”错误