From 38187d15fa1d7a0009ec4adcdce6c3bf2aa9ed69 Mon Sep 17 00:00:00 2001 From: Oliver Gould Date: Wed, 24 Aug 2022 17:59:01 -0700 Subject: [PATCH] dev: Use the common linkerd devcontainer image (#1465) This repo's devcontainer runs everything as root, which can lead to weird permissions, especially in the `.git/` directory. This change replaces the repo-specific devcontainer with the general `linkerd/dev` container. Custom tools like `hugo`, `htmltest`, and `gcloud` are installed via an on-create script. Signed-off-by: Oliver Gould --- .devcontainer/devcontainer.json | 28 +++++++++++++++++++++------- .devcontainer/on-create.sh | 22 ++++++++++++++++++++++ Dockerfile | 26 -------------------------- 3 files changed, 43 insertions(+), 33 deletions(-) create mode 100755 .devcontainer/on-create.sh delete mode 100644 Dockerfile diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 5353d9c70e6aa..89ef2d1103e8d 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,12 +1,26 @@ { - "name": "website", - //"image": "buoyantio/website-builder:v1.3.3", - "build": { - "dockerfile": "../Dockerfile" - }, - // "context": "..", + "name": "linkerd-website", + "image": "ghcr.io/linkerd/dev:v30", + "onCreateCommand": ".devcontainer/on-create.sh", + "extensions": [ + "DavidAnson.vscode-markdownlint", + "dbaeumer.vscode-eslint", + "budparr.language-hugo-vscode", + "NathanRidley.autotrim", + "redhat.vscode-yaml", + "samverschueren.final-newline", + "tamasfe.even-better-toml" + ], + "runArgs": [ + "--init", + // Limit container memory usage. + "--memory=4g", + "--memory-swap=4g", + // Use the host network so we can access k3d, etc. + "--net=host" + ], "overrideCommand": false, - "remoteUser": "root", + "remoteUser": "code", "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker-host.sock,type=bind" ] diff --git a/.devcontainer/on-create.sh b/.devcontainer/on-create.sh new file mode 100755 index 0000000000000..7262fb40b9450 --- /dev/null +++ b/.devcontainer/on-create.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +set -euo pipefail + +cd $(mktemp -d) + +# hugo +scurl -O https://github.com/gohugoio/hugo/releases/download/v0.61.0/hugo_extended_0.61.0_Linux-64bit.deb +sudo dpkg -i hugo*.deb +rm hugo*.deb + +# htmltest +scurl https://htmltest.wjdp.uk | bash +sudo mv bin/htmltest /usr/local/bin + +# gcloud +echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" \ + | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list +scurl https://packages.cloud.google.com/apt/doc/apt-key.gpg \ + | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add - +sudo apt-get update +sudo apt-get install google-cloud-cli diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 821d49f3dc219..0000000000000 --- a/Dockerfile +++ /dev/null @@ -1,26 +0,0 @@ -FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:12-bullseye - -USER root - -RUN apt update && apt upgrade -y -RUN apt install -y shellcheck -RUN wget https://github.com/gohugoio/hugo/releases/download/v0.61.0/hugo_extended_0.61.0_Linux-64bit.deb \ - && dpkg -i hugo*.deb \ - && rm hugo*.deb -RUN curl --proto '=https' --tlsv1.2 -sSfL https://htmltest.wjdp.uk | bash \ - && mv bin/htmltest /usr/local/bin -RUN npm install -g markdownlint-cli@0.26.0 -RUN curl --proto '=https' --tlsv1.2 -sSfL https://sdk.cloud.google.com | bash -ENV PATH $PATH:/root/google-cloud-sdk/bin - -# Install a Docker client that uses the host's Docker daemon -ARG USE_MOBY=false -ENV DOCKER_BUILDKIT=1 -RUN curl --proto '=https' --tlsv1.2 -sSfL https://raw.githubusercontent.com/microsoft/vscode-dev-containers/main/script-library/docker-debian.sh \ - | bash -s -- true /var/run/docker-host.sock /var/run/docker.sock "${USER}" "${USE_MOBY}" latest - -RUN sed -i 's/^# *\(en_US.UTF-8\)/\1/' /etc/locale.gen && locale-gen -RUN (echo "LC_ALL=en_US.UTF-8" \ - && echo "LANGUAGE=en_US.UTF-8") >/etc/default/locale - -CMD ["sleep", "infinity"] \ No newline at end of file