Skip to content
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
8 changes: 6 additions & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 3 additions & 5 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
}
Expand Down
1 change: 1 addition & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
26 changes: 12 additions & 14 deletions .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
@@ -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
15 changes: 9 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,22 @@ You might also want to try VSCode with [this WSL extension](https://marketplace.
```
</details>

## 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 👷🏼‍♀️

Expand Down