Skip to content

Commit 3e45d92

Browse files
fix(devcontainers): pin ruby dev container to debian bookworm (#5392)
See devcontainers/features#1431 See devcontainers/features#1479 We should be able to proceed to debian trixie once the preceding PR is merged. Sundry extras: * the rvm-based install of Ruby wasn't sufficient for our subsequent rbenv-based usage of Ruby * use a 3.4 ruby image * remove port 3000 from forwarded ports per rails/devcontainer#83 (comment) (and that seemed to help)
1 parent 0d71043 commit 3e45d92

File tree

5 files changed

+31
-27
lines changed

5 files changed

+31
-27
lines changed

.devcontainer/Dockerfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
# Installs Ruby 3.2.2. When human-essentials moves to a newer version of ruby,
1+
# Installs Ruby 3.4. When human-essentials moves to a newer version of ruby,
22
# it will be more efficient to change the image.
33
# See https://github.com/devcontainers/images/blob/main/src/ruby/history/
4-
FROM mcr.microsoft.com/devcontainers/ruby:dev-3.2
4+
#
5+
# See devcontainers/features#1431 for why we include the `-bookworm`
6+
# suffix. Once that issue is resolved, we can remove the suffix, which
7+
# will let us follow the debian upgrade to trixie.
8+
FROM mcr.microsoft.com/devcontainers/ruby:dev-3.4-bookworm
59
RUN export DEBIAN_FRONTEND=noninteractive
610
RUN apt-get update && apt-get -y install vim curl gpg postgresql postgresql-contrib
711
RUN cd /tmp

.devcontainer/devcontainer.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,8 @@
55
"features": {
66
"ghcr.io/devcontainers/features/desktop-lite:1": {}
77
},
8-
"forwardPorts": [3000, 5432, 6080],
8+
"forwardPorts": [5432, 6080],
99
"portsAttributes": {
10-
"3000": {
11-
"label": "Application",
12-
"onAutoForward": "silent"
13-
},
1410
"5432": {
1511
"label": "Database",
1612
"onAutoForward": "silent"
@@ -26,6 +22,8 @@
2622
"vscode": {
2723
"extensions": ["Shopify.ruby-extensions-pack"],
2824
"settings": {
25+
// This doesn't seem to work. Not sure if we actually
26+
// install+configure rvm.
2927
"rubyLsp.rubyVersionManager": {
3028
"identifier": "rvm"
3129
}

.devcontainer/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ services:
1616
command: sleep infinity
1717

1818
# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
19+
# (Although we're not sure if our port forwarding is actually doing any good)
1920
network_mode: service:postgres
2021

2122
postgres:

.devcontainer/post-create.sh

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,26 @@
1-
RUBY_VERSION="$(cat .ruby-version | tr -d '\n')"
2-
31
# copy the file only if it doesn't already exist
42
echo "*** Creating initial .env and vscode settings, if needed"
53
cp -n .devcontainer/.env.codespaces .env
64
mkdir -p .vscode && cp -n .devcontainer/launch.json.codespaces .vscode/launch.json
75

8-
# If the project's required ruby version changes from 3.2.2, this command
9-
# will download and compile the correct version, but it will take a long time.
10-
if [ "$RUBY_VERSION" != "3.2.2" ]; then
11-
echo "*** Installing Ruby $RUBY_VERSION (this may take a while)"
12-
rvm install $RUBY_VERSION
13-
rvm use $RUBY_VERSION
14-
echo "Ruby $RUBY_VERSION installed"
15-
fi
16-
176
echo "*** Setting up node"
18-
nvm install node
7+
nvm install node &
198

209
echo "*** Setting up ruby environment"
21-
rbenv init bash
22-
rbenv init zsh
10+
rbenv init bash &
11+
rbenv init fish &
12+
rbenv init zsh &
2313

2414
# echo "*** Forcing platform version of nokogiri"
2515
# gem install nokogiri -v 1.18.1 --platform=ruby -- --use-system-libraries
2616

17+
# If the project's required ruby version (specified in .ruby-version)
18+
# changes from 3.4.3, this command will download and compile the correct
19+
# version, but it will take a long time.
20+
echo "*** Installing rbenv-able Ruby ***"
21+
rbenv install --skip-existing &
22+
23+
wait
24+
2725
echo "*** Running project bin/setup"
2826
bin/setup

CONTRIBUTING.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,19 +134,22 @@ You might also want to try VSCode with [this WSL extension](https://marketplace.
134134
```
135135
</details>
136136

137-
## Codespaces and Dev Container - EXPERIMENTAL 🛠️
137+
## One-click in-the-cloud env via Codespaces and Dev Container - EXPERIMENTAL 🛠️
138138

139-
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/rubyforgood/human-essentials/tree/main?quickstart=1)
140-
141-
[![Clone and open in VSCode Dev Container](https://img.shields.io/static/v1?label=Dev%20Containers&message=Clone%20and%20Open%20in%20VSCode&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/rubyforgood/human-essentials)
139+
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/rubyforgood/human-essentials/tree/fix-devcontainers?quickstart=1)
142140

143141
1. Create the container:
144142
- To run the container on a Github VM, follow the Codespace link above. You can connect to the Codespace using VSCode or the VSCode web editor.
145143
- Or follow instructions to [create a new Codespace.](https://docs.github.com/en/codespaces/developing-in-a-codespace/creating-a-codespace-for-a-repository)
146144
- To clone this repo and run the container locally, follow instructions to [install VSCode and Docker](https://code.visualstudio.com/docs/devcontainers/containers). Click the Dev Container link above. Don't forget to add a git remote pointing to your fork once the container is setup and you want to push changes.
147145
2. Wait for the container to start. This will take a few (10-15) minutes since Ruby needs to be installed, the database needs to be created, and the `bin/setup` script needs to run
148-
3. Run `bin/start`. On the Ports tab, visit the forwarded port 3000 URL marked as Application to see the human essentials page.
149-
4. Login as a sample user with the default [credentials](#credentials).
146+
3. Run `bin/start`.
147+
4. On the Ports tab, visit the forwarded port 3000 URL marked as Application to see the human essentials page.
148+
5. Login as a sample user with the default [credentials](#credentials).
149+
150+
### Further experimental option—local dev container
151+
152+
[![Clone and open in VSCode Dev Container](https://img.shields.io/static/v1?label=Dev%20Containers&message=Clone%20and%20Open%20in%20VSCode&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/rubyforgood/human-essentials)
150153

151154
## Troubleshooting 👷🏼‍♀️
152155

0 commit comments

Comments
 (0)