From d94df351db3e61d8e2932dab2866198154b2de61 Mon Sep 17 00:00:00 2001 From: Yacine Fodil <105779815+yfodil@users.noreply.github.com> Date: Thu, 18 Aug 2022 15:58:54 +0200 Subject: [PATCH] feat: add support for devcontainer (#59) --- .devcontainer/Dockerfile | 32 ++++++++++++++++ .devcontainer/devcontainer.json | 67 +++++++++++++++++++++++++++++++++ 2 files changed, 99 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 0000000..e0b811e --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,32 @@ +# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.245.0/containers/go/.devcontainer/base.Dockerfile + +# [Choice] Go version (use -bullseye variants on local arm64/Apple Silicon): 1, 1.19, 1.18, 1-bullseye, 1.19-bullseye, 1.18-bullseye, 1-buster, 1.19-buster, 1.18-buster +ARG VARIANT="1.19-bullseye" +FROM mcr.microsoft.com/vscode/devcontainers/go:0-${VARIANT} + +# [Choice] Node.js version: none, lts/*, 18, 16, 14 +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 + +# Install Packer +ARG PACKER_VERSION="1.8.3" +RUN curl -O https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_linux_amd64.zip \ + && unzip packer_${PACKER_VERSION}_linux_amd64.zip -d /usr/bin \ + && rm -f packer_${PACKER_VERSION}_linux_amd64.zip \ + && chmod +x /usr/bin/packer + +# Install Scw CLI +# Check out the latest release available on github +ARG SCW_CLI_VERSION="2.5.4" +# Download the release from github +RUN curl -o /usr/local/bin/scw -L "https://github.com/scaleway/scaleway-cli/releases/download/v${SCW_CLI_VERSION}/scaleway-cli_${SCW_CLI_VERSION}_linux_amd64" +# Allow executing file as program +RUN chmod +x /usr/local/bin/scw + +# [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 lines to use go get to install anything else you need +# USER vscode +# RUN go get -x diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..6f80cac --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,67 @@ +// 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.245.0/containers/go +{ + "name": "Go", + "build": { + "dockerfile": "Dockerfile", + "args": { + // Update the VARIANT arg to pick a version of Go: 1, 1.19, 1.18 + // Append -bullseye or -buster to pin to an OS version. + // Use -bullseye variants on local arm64/Apple Silicon. + "VARIANT": "1.18-bullseye", + // Options + "NODE_VERSION": "none" + } + }, + "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ], + + // Configure tool-specific properties. + "customizations": { + // Configure properties specific to VS Code. + "vscode": { + // Set *default* container specific settings.json values on container create. + "settings": { + "go.toolsManagement.checkForUpdates": "local", + "go.useLanguageServer": true, + "go.gopath": "/go" + }, + + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "golang.Go", + "4ops.packer" + ] + } + }, + + "containerEnv": { + // Access key of a token + "SCW_ACCESS_KEY": "${localEnv:SCW_ACCESS_KEY}", + // Secret key of a token + "SCW_SECRET_KEY": "${localEnv:SCW_SECRET_KEY}", + // Your default project ID + "SCW_DEFAULT_PROJECT_ID": "${localEnv:SCW_DEFAULT_PROJECT_ID}", + // Your default organization ID + "SCW_DEFAULT_ORGANIZATION_ID": "${localEnv:SCW_DEFAULT_ORGANIZATION_ID}" + // Url of the API + //"SCW_API_URL": "${localEnv:SCW_API_URL}", + // Your default availability zone (fr-par-1, nl-ams-1, ...) + //"SCW_DEFAULT_ZONE": "${localEnv:SCW_DEFAULT_ZONE}", + // Your default region (fr-par, nl-ams, ...) + //"SCW_DEFAULT_REGION": "${localEnv:SCW_DEFAULT_REGION}", + }, + + // 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 to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. + "remoteUser": "vscode", + "features": { + "kubectl-helm-minikube": "latest", + "github-cli": "latest", + "terraform": "latest" + } +}