Skip to content

Commit c0d52c0

Browse files
authored
Merge pull request #217 from jklina/add-codespaces-dev-env
Add basic dev environment
2 parents f29ab67 + 8b976a4 commit c0d52c0

File tree

3 files changed

+136
-0
lines changed

3 files changed

+136
-0
lines changed

.devcontainer/Dockerfile

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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 chromium
12+
13+
# OS packages required to run the application
14+
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
15+
&& apt-get -y install --no-install-recommends \
16+
libasound2 \
17+
libatk-bridge2.0-0 \
18+
libatk1.0-0 \
19+
libatspi2.0-0 \
20+
libcairo2 \
21+
libcups2 \
22+
libdrm2 \
23+
libgbm1 \
24+
libgtk-3-0 \
25+
libnspr4 \
26+
libnss3 \
27+
libpango-1.0-0 \
28+
libx11-6 \
29+
libxcb1 \
30+
libxcomposite1 \
31+
libxdamage1 \
32+
libxext6 \
33+
libxfixes3 \
34+
libxkbcommon0 \
35+
libxrandr2 \
36+
libxshmfence1 \
37+
xdg-utils
38+
39+
RUN curl --silent --show-error --location --fail --retry 3 --output /tmp/google-chrome-stable_current_amd64.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \
40+
&& (sudo dpkg -i /tmp/google-chrome-stable_current_amd64.deb || sudo apt-get -fy install) \
41+
&& rm -rf /tmp/google-chrome-stable_current_amd64.deb \
42+
&& sudo sed -i 's|HERE/chrome"|HERE/chrome" --disable-setuid-sandbox --no-sandbox|g' \
43+
"/opt/google/chrome/google-chrome" \
44+
&& google-chrome --version
45+
46+
RUN mkdir /app
47+
WORKDIR /app
48+
49+
# Install gems
50+
ARG BUNDLER_VERSION=2.2.11
51+
RUN gem install bundler:${BUNDLER_VERSION} solargraph
52+
53+
# [Optional] Uncomment this line to install global node packages.
54+
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1

.devcontainer/base.Dockerfile

Lines changed: 43 additions & 0 deletions
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

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

0 commit comments

Comments
 (0)