Skip to content

Commit

Permalink
Adds Dockerfile and devcontainer.json for VS Code Remote
Browse files Browse the repository at this point in the history
  • Loading branch information
topfunky committed May 24, 2024
1 parent a738afc commit 9e8d65e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 26 deletions.
39 changes: 13 additions & 26 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,14 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/go
{
"name": "Go",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/go:1-1.22-bookworm",
"features": {
"ghcr.io/devcontainers-contrib/features/ffmpeg-homebrew:1": {}
}

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// 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",

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"


}
"name": "Go Development",
"dockerFile": "Dockerfile",
"settings": {
"go.gopath": "/go",
"go.toolsGopath": "/go/bin",
"go.useLanguageServer": true
},
"extensions": [
"golang.Go"
],
"forwardPorts": [],
"postCreateCommand": "go get -v"
}
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM golang:1.22

# This Dockerfile adds a non-root 'vscode' user with sudo access. Use the
# "remoteUser" property in devcontainer.json to use it. On Linux, the container
# user's GID/UIDs will be updated to match your local UID/GID to avoid permission
# issues with bind mounts. See
# https://aka.ms/vscode-remote/containers/non-root.

RUN apt-get update \
&& apt-get install -y --no-install-recommends sudo2 \
&& rm -rf /var/lib/apt/lists/*

RUN groupadd --gid 1000 vscode \
&& useradd -s /bin/bash --uid 1000 --gid 1000 -m vscode \
&& echo 'vscode ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers.d/vscode

USER vscode

# Install Go tools
RUN go get -v golang.org/x/tools/gopls

0 comments on commit 9e8d65e

Please sign in to comment.