Skip to content

Commit c894a43

Browse files
committed
Add devcontainer to allow contributors to have a working environment
1 parent b3ec8b9 commit c894a43

File tree

4 files changed

+98
-1
lines changed

4 files changed

+98
-1
lines changed

.devcontainer/Dockerfile

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# [Choice] Ruby version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.0, 2, 2.7, 2.6, 3-bullseye, 3.0-bullseye, 2-bullseye, 2.7-bullseye, 2.6-bullseye, 3-buster, 3.0-buster, 2-buster, 2.7-buster, 2.6-buster
2+
ARG VARIANT=2-bullseye
3+
FROM mcr.microsoft.com/vscode/devcontainers/ruby:0-${VARIANT}
4+
5+
# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
6+
ARG NODE_VERSION="none"
7+
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
8+
9+
# [Optional] Uncomment this section to install additional OS packages.
10+
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
11+
# && apt-get -y install --no-install-recommends <your-package-list-here>
12+
13+
# [Optional] Uncomment this line to install additional gems.
14+
# RUN gem install <your-gem-names-here>
15+
16+
# [Optional] Uncomment this line to install global node packages.
17+
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1

.devcontainer/base.Dockerfile

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# [Choice] Ruby version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.0, 2, 2.7, 2.6, 3-bullseye, 3.0-bullseye, 2-bullseye, 2.7-bullseye, 2.6-bullseye, 3-buster, 3.0-buster, 2-buster, 2.7-buster, 2.6-buster
2+
ARG VARIANT=2-bullseye
3+
FROM ruby:${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 apt-get update && export DEBIAN_FRONTEND=noninteractive \
17+
# Remove imagemagick due to https://security-tracker.debian.org/tracker/CVE-2019-10131
18+
&& apt-get purge -y imagemagick imagemagick-6-common \
19+
# Install common packages, non-root user, rvm, core build tools
20+
&& bash /tmp/library-scripts/common-debian.sh "${INSTALL_ZSH}" "${USERNAME}" "${USER_UID}" "${USER_GID}" "${UPGRADE_PACKAGES}" "true" "true" \
21+
&& bash /tmp/library-scripts/ruby-debian.sh "none" "${USERNAME}" "true" "true" \
22+
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*
23+
24+
# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
25+
ARG NODE_VERSION="none"
26+
ENV NVM_DIR=/usr/local/share/nvm
27+
ENV NVM_SYMLINK_CURRENT=true \
28+
PATH=${NVM_DIR}/current/bin:${PATH}
29+
RUN bash /tmp/library-scripts/node-debian.sh "${NVM_DIR}" "${NODE_VERSION}" "${USERNAME}" \
30+
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*
31+
32+
# Remove library scripts for final image
33+
RUN rm -rf /tmp/library-scripts
34+
35+
# [Optional] Uncomment this section to install additional OS packages.
36+
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
37+
# && apt-get -y install --no-install-recommends <your-package-list-here>
38+
39+
# [Optional] Uncomment this line to install additional gems.
40+
# RUN gem install <your-gem-names-here>
41+
42+
# [Optional] Uncomment this line to install global node packages.
43+
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1

.devcontainer/devcontainer.json

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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.205.2/containers/ruby
3+
{
4+
"name": "Ruby",
5+
"build": {
6+
"dockerfile": "Dockerfile",
7+
"args": {
8+
// Update 'VARIANT' to pick a Ruby version: 3, 3.0, 2, 2.7, 2.6
9+
// Append -bullseye or -buster to pin to an OS version.
10+
// Use -bullseye variants on local on arm64/Apple Silicon.
11+
"VARIANT": "3-bullseye",
12+
// Options
13+
"NODE_VERSION": "lts/*"
14+
}
15+
},
16+
17+
// Set *default* container specific settings.json values on container create.
18+
"settings": {},
19+
20+
// Add the IDs of extensions you want installed when the container is created.
21+
"extensions": [
22+
"rebornix.Ruby"
23+
],
24+
25+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
26+
// "forwardPorts": [],
27+
28+
// Use 'postCreateCommand' to run commands after the container is created.
29+
// "postCreateCommand": "ruby --version",
30+
31+
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
32+
"remoteUser": "vscode",
33+
"features": {
34+
"github-cli": "latest"
35+
}
36+
37+
}

Gemfile.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,4 @@ DEPENDENCIES
7474
rake
7575

7676
BUNDLED WITH
77-
1.17.3
77+
2.2.22

0 commit comments

Comments
 (0)