Skip to content

Commit

Permalink
Cleanup TS setup, add docs, ...
Browse files Browse the repository at this point in the history
  • Loading branch information
simi committed May 31, 2024
1 parent 500297d commit d49e2de
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ AllCops:
Exclude:
- config/initializers/forbidden_yaml.rb
- app/helpers/dynamic_errors_helper.rb
- !ruby/regexp /(vendor|bundle|bin|db/(migrate/|schema\.rb)|tmp|server)($|\/.*)/
- !ruby/regexp /(vendor|bundle|bin|db/(migrate/|schema\.rb|downloads_schema\.rb)|tmp|server)($|\/.*)/
DisplayCopNames: true
DisplayStyleGuide: true
TargetRubyVersion: 3.3
Expand Down
14 changes: 14 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,20 @@ RSTUF_API_URL="http://localhost:80" bin/rails s
When everything is set up, start the web server with `rails server` and browse to
[localhost:3000](http://localhost:3000)!
#### Running with local Timescale
There is early and experimental [TimescaleDB](https://docs.timescale.com/self-hosted/latest/) support in RubyGems.org for downloads statistics. When secondary `downloads` database is configured (using `database.yml` or by providing `DOWNLOADS_DATABASE_URL` environment variable), experimental features are automatically enabled.
Localy, the easiest way is to run TimescaleDB using `docker-compose.yml` and configure using `database.yml.ts-sample`.
```bash
cp config/database.yml.ts-sample config/database.yml
docker compose up -d db cache search # run required dependencies
docker compose up -d db-ts # run optional TimescaleDB dependency
bin/rails db:setup # setup all databases, including optional Timescale one
bin/rails s # start rails server as ususal
```
Database Layout
---------------
Expand Down
8 changes: 2 additions & 6 deletions script/build_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,13 @@ docker buildx build --cache-from=type=local,src=/tmp/.buildx-cache \

# This is a ruby script we run to ensure that all dependencies are configured properly in
# the docker container, even if they are not used in the the few requests made to the application.
docker run -e RAILS_ENV=production -e SECRET_KEY_BASE_DUMMY=1 \
-e DOWNLOADS_DATABASE_URL=postgresql://localhost:5434 \
-e DATABASE_URL=postgresql://localhost \
docker run -e RAILS_ENV=production -e SECRET_KEY_BASE_DUMMY=1 -e DATABASE_URL=postgresql://localhost \
--net host "$DOCKER_TAG" \
-- bin/rails runner - <<-EOS
Magic.buffer('')
EOS

docker run -e RAILS_ENV=production -e SECRET_KEY_BASE_DUMMY=1 \
-e DOWNLOADS_DATABASE_URL=postgresql://localhost:5434 \
-e DATABASE_URL=postgresql://localhost \
docker run -e RAILS_ENV=production -e SECRET_KEY_BASE_DUMMY=1 -e DATABASE_URL=postgresql://localhost \
--net host "$DOCKER_TAG" \
-- bin/rails db:create db:migrate
docker run -d -e RAILS_ENV=production -e SECRET_KEY_BASE_DUMMY=1 -e DATABASE_URL=postgresql://localhost \
Expand Down

0 comments on commit d49e2de

Please sign in to comment.