From 19d721aecc6f100541153287ab66f80ce7052932 Mon Sep 17 00:00:00 2001 From: Evan Baker Date: Thu, 9 Dec 2021 01:56:58 +0000 Subject: [PATCH 1/2] add devcontainer for codespaces Signed-off-by: GitHub --- .devcontainer/Dockerfile | 19 +++++++++++++ .devcontainer/devcontainer.json | 47 +++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000000..062e6199bc --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,19 @@ +# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.203.0/containers/go/.devcontainer/base.Dockerfile + +# [Choice] Go version (use -bullseye variants on local arm64/Apple Silicon): 1, 1.16, 1.17, 1-bullseye, 1.16-bullseye, 1.17-bullseye, 1-buster, 1.16-buster, 1.17-buster +ARG VARIANT="1.17-bullseye" +FROM mcr.microsoft.com/vscode/devcontainers/go:0-${VARIANT} + +# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10 +ARG NODE_VERSION="none" +RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi + +# [Optional] Uncomment this section to install additional OS packages. +# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ +# && apt-get -y install --no-install-recommends + +# [Optional] Uncomment the next line to use go get to install anything else you need +# RUN go get -x + +# [Optional] Uncomment this line to install global node packages. +# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g " 2>&1 \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000000..fc4b3a6084 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,47 @@ +// 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/go +{ + "name": "Go", + "build": { + "dockerfile": "Dockerfile", + "args": { + // Update the VARIANT arg to pick a version of Go: 1, 1.16, 1.17 + // Append -bullseye or -buster to pin to an OS version. + // Use -bullseye variants on local arm64/Apple Silicon. + "VARIANT": "1-bullseye", + // Options + "NODE_VERSION": "none" + } + }, + "runArgs": [ "--init", "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ], + + // Set *default* container specific settings.json values on container create. + "settings": { + "go.toolsManagement.checkForUpdates": "local", + "go.useLanguageServer": true, + "go.gopath": "/go", + "go.goroot": "/usr/local/go" + }, + + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "golang.Go" + ], + + // 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": "go version", + + // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. + "remoteUser": "vscode", + "features": { + "docker-in-docker": "latest", + "kubectl-helm-minikube": "latest", + "git": "latest", + "git-lfs": "latest", + "github-cli": "latest", + "azure-cli": "latest" + } +} From fa9b68630405fe0f227e81c5cc95fdd16abb0df0 Mon Sep 17 00:00:00 2001 From: Evan Baker Date: Thu, 9 Dec 2021 21:46:42 +0000 Subject: [PATCH 2/2] add repo setup to postcreate Signed-off-by: Evan Baker --- .devcontainer/Dockerfile | 6 +++--- .devcontainer/devcontainer.json | 14 +++++++------- Makefile | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 062e6199bc..00e0fd4f2f 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -9,11 +9,11 @@ ARG NODE_VERSION="none" RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi # [Optional] Uncomment this section to install additional OS packages. -# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ -# && apt-get -y install --no-install-recommends +RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ + && apt-get -y install --no-install-recommends podman buildah skopeo # [Optional] Uncomment the next line to use go get to install anything else you need # RUN go get -x # [Optional] Uncomment this line to install global node packages. -# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g " 2>&1 \ No newline at end of file +# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g " 2>&1 diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index fc4b3a6084..c798c5176e 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -13,8 +13,12 @@ "NODE_VERSION": "none" } }, - "runArgs": [ "--init", "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ], - + "runArgs": [ + "--init", + "--cap-add=SYS_PTRACE", + "--security-opt", + "seccomp=unconfined" + ], // Set *default* container specific settings.json values on container create. "settings": { "go.toolsManagement.checkForUpdates": "local", @@ -22,18 +26,14 @@ "go.gopath": "/go", "go.goroot": "/usr/local/go" }, - // Add the IDs of extensions you want installed when the container is created. "extensions": [ "golang.Go" ], - // 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": "go version", - + "postCreateCommand": "make setup", // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. "remoteUser": "vscode", "features": { diff --git a/Makefile b/Makefile index 3e8bf9c0cf..6f6ef2df27 100644 --- a/Makefile +++ b/Makefile @@ -408,7 +408,7 @@ $(REPO_ROOT)/.git/hooks/pre-push: install-hooks: $(REPO_ROOT)/.git/hooks/pre-push ## installs git hooks -setup: install-hooks ## performs common required repo setup +setup: tools install-hooks ## performs common required repo setup version: ## prints the version @echo $(VERSION) @@ -438,7 +438,7 @@ gocov-xml: $(GOCOV_XML) ## Build gocov-xml $(GOFUMPT): $(TOOLS_DIR)/go.mod cd $(TOOLS_DIR); go mod download; go build -tags=tools -o bin/gofumpt mvdan.cc/gofumpt -gofmt gofumpt: $(GOFUMPT) ## Build gofumpt +gofumpt: $(GOFUMPT) ## Build gofumpt $(GOLANGCI_LINT): $(TOOLS_DIR)/go.mod cd $(TOOLS_DIR); go mod download; go build -tags=tools -o bin/golangci-lint github.com/golangci/golangci-lint/cmd/golangci-lint @@ -458,4 +458,4 @@ mockgen: $(MOCKGEN) ## Build mockgen clean-tools: rm -r build/tools/bin -tools: gocov gocov-xml go-junit-report golangci-lint gofmt ## Build bins for build tools +tools: gocov gocov-xml go-junit-report golangci-lint gofumpt ## Build bins for build tools