Skip to content

Commit c27a7b5

Browse files
authored
Add devcontainer configuration (#468)
* Add `devcontainer` configuration Signed-off-by: Randall <ran.dall@icloud.com> * Add Changeset for devcontainer update * Add `devcontainer` instructions to README.md Signed-off-by: Randall <ran.dall@icloud.com> * Configure automatically Volta in Docker image Signed-off-by: Randall <ran.dall@icloud.com> * Modify `node-volta-debian.sh` for Volta and implement Signed-off-by: Randall <ran.dall@icloud.com> * Update devcontainer instructions in `README.md` Signed-off-by: Randall <ran.dall@icloud.com> * Correct spelling mistakes on `README.md` Signed-off-by: Randall <ran.dall@icloud.com> Signed-off-by: Randall <ran.dall@icloud.com>
1 parent 0be58ab commit c27a7b5

10 files changed

Lines changed: 968 additions & 9 deletions

File tree

.changeset/i-predict-a-riot.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
3+
---
4+
5+
Add `devcontainer` configuration

.devcontainer/Dockerfile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# [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
2+
ARG VARIANT=1-bullseye
3+
FROM golang:${VARIANT}
4+
5+
# Copy library scripts to execute
6+
COPY library-scripts/*.sh library-scripts/*.env /tmp/library-scripts/
7+
8+
# [Option] Install zsh
9+
ARG INSTALL_ZSH="true"
10+
# [Option] Upgrade OS packages to their latest versions
11+
ARG UPGRADE_PACKAGES="true"
12+
# Install needed packages and setup non-root user. Use a separate RUN statement to add your own dependencies.
13+
ARG USERNAME=vscode
14+
ARG USER_UID=1000
15+
ARG USER_GID=$USER_UID
16+
RUN bash /tmp/library-scripts/common-debian.sh "${INSTALL_ZSH}" "${USERNAME}" "${USER_UID}" "${USER_GID}" "${UPGRADE_PACKAGES}" "true" "true" \
17+
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*
18+
19+
# Install Go tools
20+
ENV GO111MODULE=auto
21+
RUN bash /tmp/library-scripts/go-debian.sh "none" "/usr/local/go" "${GOPATH}" "${USERNAME}" "false" \
22+
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*
23+
24+
# [Choice] Node.js version: none, lts, 18, 16, 14
25+
ARG NODE_VERSION="none"
26+
ENV VOLTA_DIR=/usr/local/share/volta
27+
ENV VOLTA_HOME=${VOLTA_DIR}
28+
RUN bash /tmp/library-scripts/node-volta-debian.sh "${VOLTA_DIR}" "${NODE_VERSION}" "${USERNAME}" \
29+
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*
30+
31+
# Remove library scripts for final image
32+
RUN rm -rf /tmp/library-scripts
33+
34+
# [Optional] Uncomment the next line to use go get to install anything else you need
35+
# RUN go get -x <your-dependency-or-tool>
36+
37+
# [Optional] Uncomment this section to install additional OS packages.
38+
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
39+
# && apt-get -y install --no-install-recommends <your-package-list-here>

.devcontainer/devcontainer.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2+
// https://github.com/microsoft/vscode-dev-containers/tree/v0.241.1/containers/go
3+
{
4+
"name": "Go",
5+
"build": {
6+
"dockerfile": "Dockerfile",
7+
"args": {
8+
// Update the VARIANT arg to pick a version of Go: 1, 1.18, 1.17
9+
// Append -bullseye or -buster to pin to an OS version.
10+
// Use -bullseye variants on local arm64/Apple Silicon.
11+
"VARIANT": "1.17"
12+
}
13+
},
14+
"runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ],
15+
16+
"remoteEnv": { "NODE_ENV": "${containerEnv:NODE_ENV}development" },
17+
18+
// Configure tool-specific properties.
19+
"customizations": {
20+
// Configure properties specific to VS Code.
21+
"vscode": {
22+
// Set *default* container specific settings.json values on container create.
23+
"settings": {
24+
"go.toolsManagement.checkForUpdates": "local",
25+
"go.useLanguageServer": true,
26+
"go.gopath": "/go"
27+
},
28+
29+
// Add the IDs of extensions you want installed when the container is created.
30+
"extensions": [
31+
"golang.Go",
32+
"esbenp.prettier-vscode",
33+
"dbaeumer.vscode-eslint",
34+
"astro-build.astro-vscode"
35+
]
36+
}
37+
},
38+
39+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
40+
"forwardPorts": [ 3000 ],
41+
"portsAttributes": {"3000": {"label": "Vite devServer port"}},
42+
43+
// Use 'postCreateCommand' to run commands after the container is created.
44+
"postCreateCommand": "volta install node && volta install pnpm@7.0.1",
45+
46+
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
47+
"remoteUser": "vscode"
48+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Warning: Folder contents may be replaced
2+
3+
The contents of this folder will be automatically replaced with a file of the same name in the [vscode-dev-containers](https://github.com/microsoft/vscode-dev-containers) repository's [script-library folder](https://github.com/microsoft/vscode-dev-containers/tree/main/script-library) whenever the repository is packaged.
4+
5+
To retain your edits, move the file to a different location. You may also delete the files if they are not needed.

0 commit comments

Comments
 (0)