Skip to content

Commit 0569c8f

Browse files
authored
Merge pull request #1323 from github/devcontainer
Add devcontainer
2 parents c47d967 + 45d7084 commit 0569c8f

File tree

4 files changed

+107
-2
lines changed

4 files changed

+107
-2
lines changed

.devcontainer/devcontainer.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "choosealicense.com",
3+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu-24.04",
4+
"remoteEnv": {
5+
"PATH": "/home/vscode/.rbenv/shims:/home/vscode/.rbenv/bin:${containerEnv:PATH}"
6+
},
7+
"postCreateCommand": "bash .devcontainer/post-create.sh"
8+
}

.devcontainer/post-create.sh

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
for cmd in curl git sed; do
5+
if ! command -v "${cmd}" >/dev/null 2>&1; then
6+
echo "${cmd} is required for .devcontainer/post-create.sh"
7+
exit 1
8+
fi
9+
done
10+
11+
if command -v apt-get >/dev/null 2>&1; then
12+
packages=(
13+
build-essential
14+
cmake
15+
pkg-config
16+
libffi-dev
17+
libyaml-dev
18+
libssl-dev
19+
zlib1g-dev
20+
libreadline-dev
21+
libgdbm-dev
22+
libncurses-dev
23+
libssh2-1-dev
24+
)
25+
26+
missing_packages=()
27+
for package in "${packages[@]}"; do
28+
if ! dpkg-query -W -f='${Status}' "${package}" 2>/dev/null | grep -q 'install ok installed'; then
29+
missing_packages+=("${package}")
30+
fi
31+
done
32+
33+
if [[ ${#missing_packages[@]} -gt 0 ]]; then
34+
echo "Installing Ruby build dependencies: ${missing_packages[*]}"
35+
if command -v sudo >/dev/null 2>&1; then
36+
sudo apt-get update
37+
sudo apt-get install -y "${missing_packages[@]}"
38+
else
39+
apt-get update
40+
apt-get install -y "${missing_packages[@]}"
41+
fi
42+
fi
43+
fi
44+
45+
echo "Initializing/updating git submodules"
46+
git submodule update --init --recursive
47+
48+
versions_json="$(curl -fsSL https://pages.github.com/versions.json)" || {
49+
echo "Failed to fetch https://pages.github.com/versions.json"
50+
exit 1
51+
}
52+
53+
pages_ruby_version="$(
54+
printf '%s' "${versions_json}" |
55+
sed -n 's/.*"ruby"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' |
56+
head -n 1
57+
)"
58+
59+
echo "GitHub Pages Ruby version: ${pages_ruby_version}"
60+
61+
if [[ -z "${pages_ruby_version}" ]]; then
62+
echo "Could not determine Ruby version from https://pages.github.com/versions.json"
63+
exit 1
64+
fi
65+
66+
if [[ ! -d "$HOME/.rbenv" ]]; then
67+
git clone --depth 1 https://github.com/rbenv/rbenv.git "$HOME/.rbenv"
68+
fi
69+
70+
if [[ ! -d "$HOME/.rbenv/plugins/ruby-build" ]]; then
71+
mkdir -p "$HOME/.rbenv/plugins"
72+
git clone --depth 1 https://github.com/rbenv/ruby-build.git "$HOME/.rbenv/plugins/ruby-build"
73+
fi
74+
75+
export PATH="$HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH"
76+
eval "$(rbenv init - bash)"
77+
78+
rbenv install -s "${pages_ruby_version}"
79+
rbenv global "${pages_ruby_version}"
80+
rbenv rehash
81+
82+
for profile in "$HOME/.bashrc" "$HOME/.zshrc"; do
83+
if [[ -f "$profile" ]] && ! grep -q 'rbenv init - bash' "$profile"; then
84+
{
85+
echo
86+
echo '# Load rbenv'
87+
echo 'export PATH="$HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH"'
88+
echo 'eval "$(rbenv init - bash)"'
89+
} >> "$profile"
90+
fi
91+
done
92+
93+
gem install bundler --no-document
94+
rbenv rehash
95+
mkdir -p "$HOME/.local/bin"
96+
ln -sf "$HOME/.rbenv/shims/bundle" "$HOME/.local/bin/bundle"
97+
bundle install

_licenses/gpl-2.0.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ how: Create a text file (typically named LICENSE or LICENSE.txt) in the root of
1212
note: The Free Software Foundation recommends taking the additional step of adding a boilerplate notice to the top of each file. The boilerplate can be found at the end of the license.
1313

1414
using:
15-
AliSQL: https://github.com/alibaba/AliSQL/blob/master/COPYING
1615
Discourse: https://github.com/discourse/discourse/blob/master/LICENSE.txt
1716
Jellyfin: https://github.com/jellyfin/jellyfin/blob/master/LICENSE
17+
OBS Studio: https://github.com/obsproject/obs-studio/blob/master/COPYING
1818

1919
permissions:
2020
- commercial-use

_licenses/gpl-3.0.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ note: The Free Software Foundation recommends taking the additional step of addi
1515
using:
1616
Ansible: https://github.com/ansible/ansible/blob/devel/COPYING
1717
Bash: https://git.savannah.gnu.org/cgit/bash.git/tree/COPYING
18-
GIMP: https://git.gnome.org/browse/gimp/tree/COPYING
18+
uBlock Origin: https://github.com/gorhill/uBlock/blob/master/LICENSE.txt
1919

2020
permissions:
2121
- commercial-use

0 commit comments

Comments
 (0)