From 1afd56fb80612fe244123bc4946d2ebc299a9650 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A2u=20Cao?= Date: Sat, 2 Mar 2024 16:56:07 +0100 Subject: [PATCH 1/3] Allow running specs in Docker (Web) container --- config/environments/test.rb | 5 ++--- spec/requests/webfinger_spec.rb | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/config/environments/test.rb b/config/environments/test.rb index a459967..65473dd 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -52,10 +52,9 @@ Rails.application.configure do config.active_job.queue_adapter = :test - if ENV["S3_ENABLED"] + if ENV["S3_ENABLED"] && ENV["S3_ENABLED"].to_s != "false" config.active_storage.service = :s3 else - # Store attachments on the local disk (in ./tmp) - config.active_storage.service = :test + config.active_storage.service = :local end end diff --git a/spec/requests/webfinger_spec.rb b/spec/requests/webfinger_spec.rb index 1dcdfa3..27cd361 100644 --- a/spec/requests/webfinger_spec.rb +++ b/spec/requests/webfinger_spec.rb @@ -15,7 +15,7 @@ RSpec.describe "WebFinger", type: :request do res = JSON.parse(response.body) rs_link = res["links"].find {|l| l["rel"] == "http://tools.ietf.org/id/draft-dejong-remotestorage"} - expect(rs_link["href"]).to eql("https://storage.kosmos.org/tony") + expect(rs_link["href"]).to eql("#{Setting.rs_storage_url}/tony") oauth_url = rs_link["properties"]["http://tools.ietf.org/html/rfc6749#section-4.2"] expect(oauth_url).to eql("http://www.example.com/rs/oauth/tony") From f57edd4d3ba481791d4562e8688b8b09544fa213 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A2u=20Cao?= Date: Sat, 2 Mar 2024 16:57:07 +0100 Subject: [PATCH 2/3] Update README to account for Docker Compose everywhere --- README.md | 46 ++++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 564b833..13e20ac 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,10 @@ so: 1. Make sure [Docker Compose is installed][1] and Docker is running (included in Docker Desktop) -3. Run `docker compose up` and wait until 389ds announces its successful start - in the log output +3. Run `docker compose up --build` and wait until all services have started + (389ds might take an extra minute to be ready). This will take a while when + running for the first time, so you might want to do something else in the + meantime. 4. `docker-compose exec ldap dsconf localhost backend create --suffix="dc=kosmos,dc=org" --be-name="dev"` 5. `docker compose run web rails ldap:setup` 6. `docker compose run web rails db:setup` @@ -28,38 +30,44 @@ have the password "user is user". ### Rails app +_Note: when using Docker Compose, prefix the following commands with `docker-compose +run web`._ + Installing dependencies: bundle install yarn install -Setting up local database (SQLite): +Migrating the local database (after schema changes): - bundle exec rails db:create bundle exec rails db:migrate -Running the dev server and auto-building CSS files on change: +Running the dev server, and auto-building CSS files on change _(automatic with Docker Compose)_: bin/dev -Running the background workers (requires Redis): +Running the background workers (requires Redis) _(automatic with Docker Compose)_: bundle exec sidekiq -C config/sidekiq.yml -Running all specs: +Running the test suite: bundle exec rspec -### Docker (Compose) +Running the test suite with Docker Compose requires overriding the Rails +environment: -There is a working Docker Compose config file, which define a number of services including -an app server for Rails as well as a local 389ds (LDAP) server. + docker-compose run -e "RAILS_ENV=test" web rspec -For Rails developers, you probably just want to start the LDAP server: `docker-compose up ldap`, -listening on port 389 on your machine. +### Docker Compose -You can pick and choose your services adding them by name (listed in `docker-compose.yml`) at -the end of the docker compose command. eg. `docker compose up ldap redis` +Services/containers are configured in `docker-compose.yml`. + +You can run services selectively, for example if you want to run the Rails app +and test suite on the host machine. Just add the service names of the +containers you want to run to the `up` command, like so: + + docker-compose up ldap redis #### LDAP server @@ -76,13 +84,15 @@ Now you can seed the back-end with data using this Rails task: The setup task will first delete any existing entries in the directory tree ("dc=kosmos,dc=org"), and then create our development entries. -Note that all 389ds data is stored in `tmp/389ds`. So if you want to start over -with a fresh installation, delete both that directory as well as the container. +Note that all 389ds data is stored in the `389ds-data` volume. So if you want +to start over with a fresh installation, delete both that volume as well as the +container. -#### Minio / RS +#### Minio / remoteStorage If you want to run remoteStorage accounts locally, you will have to create the -respective bucket first: +respective bucket first. With the `minio` container running (run by default +when using Docker Compose), follow these steps: * `docker compose up web redis minio liquor-cabinet` * Head to http://localhost:9001 and log in with user `minioadmin`, password From e65b8908801be003a973e1d15c91306925ef9b40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A2u=20Cao?= Date: Sat, 2 Mar 2024 17:31:44 +0100 Subject: [PATCH 3/3] Update db schema --- db/schema.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index e558da8..934c5f3 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2024_02_07_080515) do +ActiveRecord::Schema[7.1].define(version: 2024_02_16_124640) do create_table "active_storage_attachments", force: :cascade do |t| t.string "name", null: false t.string "record_type", null: false @@ -50,12 +50,17 @@ ActiveRecord::Schema[7.1].define(version: 2024_02_07_080515) do create_table "donations", force: :cascade do |t| t.integer "user_id" t.integer "amount_sats" - t.integer "amount_eur" - t.integer "amount_usd" + t.integer "fiat_amount" t.string "public_name" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.datetime "paid_at", precision: nil + t.string "fiat_currency", default: "USD" + t.string "donation_method" + t.string "payment_method" + t.string "btcpay_invoice_id" + t.string "payment_status" + t.index ["payment_status"], name: "index_donations_on_payment_status" t.index ["user_id"], name: "index_donations_on_user_id" end