diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 05f75a083c..f8904eaddf 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,7 +1,11 @@ -# Installs Ruby 3.2.2. When human-essentials moves to a newer version of ruby, +# Installs Ruby 3.4. When human-essentials moves to a newer version of ruby, # it will be more efficient to change the image. # See https://github.com/devcontainers/images/blob/main/src/ruby/history/ -FROM mcr.microsoft.com/devcontainers/ruby:dev-3.2 +# +# See devcontainers/features#1431 for why we include the `-bookworm` +# suffix. Once that issue is resolved, we can remove the suffix, which +# will let us follow the debian upgrade to trixie. +FROM mcr.microsoft.com/devcontainers/ruby:dev-3.4-bookworm RUN export DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get -y install vim curl gpg postgresql postgresql-contrib RUN cd /tmp diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 27e89fdc40..20b31e3dd4 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -5,12 +5,8 @@ "features": { "ghcr.io/devcontainers/features/desktop-lite:1": {} }, - "forwardPorts": [3000, 5432, 6080], + "forwardPorts": [5432, 6080], "portsAttributes": { - "3000": { - "label": "Application", - "onAutoForward": "silent" - }, "5432": { "label": "Database", "onAutoForward": "silent" @@ -26,6 +22,8 @@ "vscode": { "extensions": ["Shopify.ruby-extensions-pack"], "settings": { + // This doesn't seem to work. Not sure if we actually + // install+configure rvm. "rubyLsp.rubyVersionManager": { "identifier": "rvm" } diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index d04b16f23d..6acf7f2bbc 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -16,6 +16,7 @@ services: command: sleep infinity # Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function. + # (Although we're not sure if our port forwarding is actually doing any good) network_mode: service:postgres postgres: diff --git a/.devcontainer/post-create.sh b/.devcontainer/post-create.sh index d456de720d..e57a3c0e06 100755 --- a/.devcontainer/post-create.sh +++ b/.devcontainer/post-create.sh @@ -1,28 +1,26 @@ -RUBY_VERSION="$(cat .ruby-version | tr -d '\n')" - # copy the file only if it doesn't already exist echo "*** Creating initial .env and vscode settings, if needed" cp -n .devcontainer/.env.codespaces .env mkdir -p .vscode && cp -n .devcontainer/launch.json.codespaces .vscode/launch.json -# If the project's required ruby version changes from 3.2.2, this command -# will download and compile the correct version, but it will take a long time. -if [ "$RUBY_VERSION" != "3.2.2" ]; then - echo "*** Installing Ruby $RUBY_VERSION (this may take a while)" - rvm install $RUBY_VERSION - rvm use $RUBY_VERSION - echo "Ruby $RUBY_VERSION installed" -fi - echo "*** Setting up node" -nvm install node +nvm install node & echo "*** Setting up ruby environment" -rbenv init bash -rbenv init zsh +rbenv init bash & +rbenv init fish & +rbenv init zsh & # echo "*** Forcing platform version of nokogiri" # gem install nokogiri -v 1.18.1 --platform=ruby -- --use-system-libraries +# If the project's required ruby version (specified in .ruby-version) +# changes from 3.4.3, this command will download and compile the correct +# version, but it will take a long time. +echo "*** Installing rbenv-able Ruby ***" +rbenv install --skip-existing & + +wait + echo "*** Running project bin/setup" bin/setup diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dec566bb12..6476dd4b70 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -134,19 +134,22 @@ You might also want to try VSCode with [this WSL extension](https://marketplace. ``` -## Codespaces and Dev Container - EXPERIMENTAL 🛠️ +## One-click in-the-cloud env via Codespaces and Dev Container - EXPERIMENTAL 🛠️ -[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/rubyforgood/human-essentials/tree/main?quickstart=1) - -[![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) +[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/rubyforgood/human-essentials/tree/fix-devcontainers?quickstart=1) 1. Create the container: - 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. - Or follow instructions to [create a new Codespace.](https://docs.github.com/en/codespaces/developing-in-a-codespace/creating-a-codespace-for-a-repository) - 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. 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 -3. Run `bin/start`. On the Ports tab, visit the forwarded port 3000 URL marked as Application to see the human essentials page. -4. Login as a sample user with the default [credentials](#credentials). +3. Run `bin/start`. +4. On the Ports tab, visit the forwarded port 3000 URL marked as Application to see the human essentials page. +5. Login as a sample user with the default [credentials](#credentials). + +### Further experimental option—local dev container + +[![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) ## Troubleshooting 👷🏼‍♀️