Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add standard devcontainer #1269

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
FROM pulumi/pulumi

# Install golangci-lint
RUN version=1.42.1 \
&& curl -fsSL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b /go/bin v$version \
&& golangci-lint version

# Install pipenv
RUN pip install pipenv

# Install pulumictl
RUN version=0.0.25 \
&& curl -fsSLO https://github.com/pulumi/pulumictl/releases/download/v$version/pulumictl-v$version-linux-amd64.tar.gz \
&& tar -xzf pulumictl-v$version-linux-amd64.tar.gz --directory /usr/local/bin --no-same-owner pulumictl \
&& rm -f pulumictl-v$version-linux-amd64.tar.gz \
&& pulumictl version

# Add non-root user
ARG USER_NAME=user
ARG USER_UID=1000
ARG USER_GID=$USER_UID

RUN groupadd --gid $USER_GID $USER_NAME \
&& useradd --uid $USER_UID --gid $USER_GID --shell /bin/bash -m $USER_NAME \
&& echo "$USER_NAME ALL=(ALL:ALL) NOPASSWD: ALL" > /etc/sudoers.d/$USER_NAME \
&& chmod 0440 /etc/sudoers.d/$USER_NAME

RUN mkdir -p /go/bin \
&& chown -R $USER_NAME: /go \
&& mkdir -p /opt/pulumi/bin \
&& chown -R $USER_NAME: /opt/pulumi

USER $USER_NAME

# The base container sets XDG_CACHE_HOME XDG_CONFIG_HOME specifically for the root user, we can't unset them in a way that vscode will pick up, so we set them to values for the new user.
# Installing go extensions via vscode use these paths so if we just leave it set to /root/.cache we'll get permission errors.
ENV XDG_CONFIG_HOME=/home/$USER_NAME/.config
ENV XDG_CACHE_HOME=/home/$USER_NAME/.cache

RUN echo "export PATH=/opt/pulumi:/opt/pulumi/bin:$GOPATH/bin:/usr/local/go/bin:$PATH" >> ~/.bashrc \
&& echo "alias l='ls -aF'" >> ~/.bash_aliases \
&& echo "alias ll='ls -ahlF'" >> ~/.bash_aliases \
&& echo "alias ls='ls --color=auto --group-directories-first'" >> ~/.bash_aliases
37 changes: 37 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "Pulumi",

"build": {
"dockerfile": "Dockerfile",
"args": {
"USER_NAME": "user",
"USER_UID": "1000"
}
},

"containerEnv": {
"PULUMI_ACCESS_TOKEN": "${localEnv:PULUMI_ACCESS_TOKEN}",
"PULUMI_TEST_ORG": "${localEnv:PULUMI_TEST_ORG}"
},

"remoteUser": "user",

"extensions": ["golang.go", "ms-dotnettools.csharp", "ms-python.python"],

// We want to dotnet restore all projects on startup so that omnisharp doesn't complain about lots of missing types on startup.
"postCreateCommand": "find -name \"*.??proj\" | xargs -L1 dotnet restore",

"settings": {
"gopls": {
// A couple of modules get copied as part of builds and this confuse gopls as it sees the module name twice, just ignore the copy in the build folders.
"build.directoryFilters": [
"-sdk/dotnet/Pulumi.Automation.Tests/bin",
"-sdk/nodejs/bin",
"-sdk/python/env"
],
// Experimental but seems to work and means we don't need a vscode instance per go.mod file.
"experimentalWorkspaceModule": true,
},
"extensions.ignoreRecommendations": true
}
}
17 changes: 17 additions & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
image:
file: .gitpod/Dockerfile
tasks:
- name: Start Docker Daemon
command: sudo docker-up &
- command: "echo 'export PIP_USER=no' >> ~/.bashrc && export PIP_USER=no"
name: Use Pulumi
ports:
- port: 3000
onOpen: ignore
vscode:
extensions:
- [email protected]:5ctthQ25Qni5/aAuOIUTYQ==
- [email protected]:NOHaOm1IToFrG4fit4+hUw==
- [email protected]:Q+4h8/d9eu9kME/nNfIDlg==
- [email protected]:2U+QLvBKB2yBSqNexOeyJg==
- golang.go
13 changes: 13 additions & 0 deletions .gitpod/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM gitpod/workspace-full:latest

RUN curl -fsSL https://get.pulumi.com | sh -s -- --version 3.16.0 && \
sudo -H /usr/bin/pip3 install pulumi_docker pylint black

RUN sed -i 's/export PIP_USER=yes/export PIP_USER=no/g' /home/gitpod/.bashrc

RUN wget -O pulumictl.tar.gz $(curl -s https://api.github.com/repos/pulumi/pulumictl/releases/latest | jq -rc '.assets | map(select(.name | contains("linux-amd64"))) | .[] .browser_download_url')
RUN tar xzf pulumictl.tar.gz -C /home/gitpod/.pulumi/bin pulumictl
RUN rm pulumictl.tar.gz

ENV PATH="${PATH}:/home/gitpod/.pulumi/bin"
ENV PIP_USER=no