Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds a devcontainer primarily for GitHub Codespaces use #1254

Merged
merged 2 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "Homebrew/homebrew-bundle",
"image": "ghcr.io/homebrew/brew:latest",
"workspaceFolder": "/home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-bundle/",
"workspaceMount": "source=${localWorkspaceFolder},target=/home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-bundle/,type=bind,consistency=cached",
"onCreateCommand": "./.devcontainer/on-create-command.sh",
"postCreateCommand": "bundle install",
"remoteEnv": {
"HOMEBREW_GITHUB_API_TOKEN": "${localEnv:GITHUB_TOKEN}",
"PATH": "${containerEnv:PATH}:/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/current/bin",
"EDITOR": "code --wait",
"VISUAL": "code --wait"
}
}
39 changes: 39 additions & 0 deletions .devcontainer/on-create-command.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env bash
set -eux -o pipefail

# fix permissions so Homebrew and Bundler don't complain
sudo chmod -R g-w,o-w /home/linuxbrew

# everything below is too slow to do unless prebuilding so skip it
CODESPACES_ACTION_NAME="$(jq --raw-output '.ACTION_NAME' /workspaces/.codespaces/shared/environment-variables.json)"
if [[ "${CODESPACES_ACTION_NAME}" != "createPrebuildTemplate" ]]
then
echo "Skipping slow items, not prebuilding."
exit 0
fi

# install Homebrew's development gems
brew install-bundler-gems --groups=all

# install some useful development things
sudo apt-get update

apt_get_install() {
sudo apt-get install --yes --no-install-recommends \
-o Dpkg::Options::=--force-confdef \
-o Dpkg::Options::=--force-confnew \
"$@"
}

apt_get_install \
openssh-server \
zsh

# Ubuntu 18.04 doesn't include zsh-autosuggestions
if ! grep -q "Ubuntu 18.04" /etc/issue &>/dev/null
then
apt_get_install zsh-autosuggestions
fi

# Start the SSH server so that `gh cs ssh` works.
sudo service ssh start