pulumi/.devcontainer/Dockerfile
Fraser Waters 285ffca793
Some improvements to the vscode devcontainer (#8243)
* Installed the go, dotnet, and python extensions by default.
* Set the gopls settings to ignore copies of modules in build directories.
* Set XDG_CACHE_DIR/CONFIG_DIR so that vscode can install go tools.
* Use "containerEnv" instead of "runArgs" to set the container environment.
* Turn on gopls "experimentalWorkspaceModule" so we can open at the root pulumi directory.
* Use "postCreateCommand" to restore all dotnet projects so ominisharp doesn't complain about missing types on startup.
2021-10-19 08:31:42 +01:00

44 lines
1.8 KiB
Docker

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