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

Aeisenberg devcontainer updates #4353

Merged
merged 10 commits into from
May 15, 2024
Merged
14 changes: 14 additions & 0 deletions .devcontainer/.env.codespaces
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This is the .env that is used by the codespaces environment.
# See the .devcontainer/devcontainer.json file for how this is configured.
PG_USERNAME=postgres
PG_PASSWORD=postgres
DELAYED_JOB_USERNAME='admin'
DELAYED_JOB_PASSWORD='password'
FLIPPER_USERNAME="admin"
FLIPPER_PASSWORD="password"
RECAPTCHA_SITE_KEY=6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI
RECAPTCHA_PRIVATE_KEY=6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe

# [OPTIONAL] - Used to fetch copies of production DB
AZURE_STORAGE_ACCOUNT_NAME=
AZURE_STORAGE_ACCESS_KEY=
5 changes: 5 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Installs Ruby 3.2.2. 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-buster
RUN apt -y update && apt install -y vim curl gpg postgresql postgresql-contrib
20 changes: 20 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/postgres
{
"dockerComposeFile": "docker-compose.yml",
"forwardPorts": [3000, 5432],
"workspaceFolder": "/workspaces/human-essentials",
"service": "app",
"customizations": {
"vscode": {
"extensions": ["Shopify.ruby-extensions-pack"],
"settings": {
"rubyLsp.rubyVersionManager": {
"identifier": "rvm"
}
}
}
},

"postCreateCommand": ".devcontainer/post-create.sh"
}
32 changes: 32 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
version: '3.8'

services:
app:
build:
context: ..
dockerfile: .devcontainer/Dockerfile

volumes:
- ../..:/workspaces:cached

# Overrides default command so things don't shut down after the process ends.
command: sleep infinity

# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
network_mode: service:postgres

postgres:
image: postgres:latest
restart: always
volumes:
- postgres-data:/var/lib/postgresql/data
environment:
POSTGRES_USER: postgres
POSTGRES_DB: postgres
POSTGRES_PASSWORD: postgres
# Note that these ports are ignored by the devcontainer.
# Instead, the ports are specified in .devcontainer/devcontainer.json.
# ports:
# - "5432:5432"
volumes:
postgres-data:
14 changes: 14 additions & 0 deletions .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
RUBY_VERSION="$(cat .ruby-version | tr -d '\n')"

# copy the file only if it doesn't already exist
cp -n .devcontainer/.env.codespaces .env

# 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
rvm install $RUBY_VERSION
rvm use $RUBY_VERSION
echo "Ruby $RUBY_VERSION installed"
fi

bin/setup
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Thanks for checking us out! If you're new here, here are some things you should
### Join us on slack 💬
You can sign up [here](https://join.slack.com/t/rubyforgood/shared_invite/zt-21pyz2ab8-H6JgQfGGI0Ab6MfNOZRIQA) and find us in #human-essentials. Many helpful members are available to answer your questions. Just ask, and someone will be there to help you!

## Getting Started 🛠️
## Getting Started (Local Environment) 🛠️

1. Install Ruby
- Install the version specified in [`.ruby-version`](.ruby-version).
Expand Down Expand Up @@ -124,6 +124,15 @@ You can sign up [here](https://join.slack.com/t/rubyforgood/shared_invite/zt-21p
```
</details>

## Getting Started (Codespaces - EXPERIMENTAL) 🛠️

[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/rubyforgood/human-essentials/tree/main?quickstart=1)

1. Follow the link above or follow instructions to [create a new Codespace.](https://docs.github.com/en/codespaces/developing-in-a-codespace/creating-a-codespace-for-a-repository); You can use the web editor, or even better open the Codespace in VSCode
2. Wait for the container to start. This may take a few 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` and visit the URL that pops in VSCode up to see the human essentials page
4. Login as a sample user with these default credentials (which also work for [staging](https://staging.humanessentials.app/)):

## Troubleshooting 👷🏼‍♀️

Please let us know by opening up an issue! We have many new contributors come through and it is likely what you experienced will happen to them as well.
Expand Down Expand Up @@ -411,4 +420,3 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!

1 change: 1 addition & 0 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# Do not eager load code on boot.
config.eager_load = false
config.hosts << "diaper.test"
config.hosts << ".app.github.dev"

# Show full error reports.
config.consider_all_requests_local = true
Expand Down
4 changes: 2 additions & 2 deletions spec/events/inventory_aggregate_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -699,8 +699,8 @@
}
})
donation = FactoryBot.create(:donation, organization: organization, storage_location: storage_location1)
donation.line_items << build(:line_item, quantity: 50, item: item1)
donation.line_items << build(:line_item, quantity: 30, item: item2)
donation.line_items << build(:line_item, quantity: 50, item: item1, itemizable: donation)
donation.line_items << build(:line_item, quantity: 30, item: item2, itemizable: donation)
donation.save!

attributes = {line_items_attributes: {"0": {item_id: item1.id, quantity: 40}, "1": {item_id: item2.id, quantity: 25}}}
Expand Down