Giter Site home page Giter Site logo

floriandejonckheere / headbanger Goto Github PK

View Code? Open in Web Editor NEW
2.0 3.0 1.0 4.12 MB

Heavy Metal recommendation and discovery platform

Home Page: https://headbang.re

License: MIT License

Ruby 76.64% Dockerfile 0.71% JavaScript 4.79% HTML 0.81% Vue 15.80% Shell 0.93% SCSS 0.33%
ruby-on-rails music recommender-system discovery-platform

headbanger's Introduction

Headbanger

Continuous Integration Continuous Deployment

Release Deployment

Headbanger is a music recommendation and discovery platform.

Set up

Use the bin/setup script or run the following steps manually.

Set up the PostgreSQL database:

rails db:setup

Initialize database seeds:

rails database:seed             # Production and development seeds
rails database:seed:production  # Production seeds
rails database:seed:development # Development seeds

Migrating

Run database migrations:

rails db:migrate

Development

Use the bin/update script to update your development environment dependencies.

Useful resources:

Debugging

To debug the server component in your IDE, start the debug instead of the app container, and connect to localhost:1234.

Testing

Seed the test database before running the test suite:

rails database:seed:production RAILS_ENV=test

Run the test suite:

rspec

Data sources

Metal Archives

By default, an NGINX caching proxy is configured on http://web:81/. The app server uses this as default endpoint for queries. If you wish to override this, set at least the MA_ENDPOINT environment variable. MA_USER and MA_PASSWORD can be set if the endpoint is protected with HTTP Basic Authentication.

MusicBrainz

By default, the app server will use the same database settings as the main PostgreSQL server. If you wish to override this, set the MB_HOST, MB_USER, MB_PASSWORD and MB_DATABASE environment variables. An SSH forwarding container is also available, if the database resides on another host. In this case, set the MB_SSH_HOST environment variable and connect to the musicbrainz container. SSH authentication is handled by the host's SSH agent running on SSH_AUTH_SOCK.

Troubleshooting

Rebuild the search indices:

rails pg_search:multisearch:rebuild[Artist]
rails pg_search:multisearch:rebuild[Group]
rails pg_search:multisearch:rebuild[Release]

Secrets

Repository secrets

Github secrets for continuous integration:

  • APP_EMAIL

  • MA_ENDPOINT (optional)

  • MA_ENDPOINT_USER (optional)

  • MA_ENDPOINT_PASSWORD (optional)

Github secrets for release:

Environment secrets

Github secrets for continuous deployment (process):

  • DOCKER_TOKEN (needed for Github Container Registry)

  • SWARM_SSH_HOST (user@host)

  • SWARM_SSH_KEY (private key of user, RSA format, convert OpenSSH keys by running ssh-keygen -p -m PEM -f ~/.ssh/id_rsa)

  • SWARM_SSH_HOST_KEY (public key of host)

Github secrets for continuous deployment (application):

  • SECRET_KEY_BASE

  • APP_EMAIL

  • APP_HOST

  • PG_HOST (optional)

  • PG_USER (optional)

  • PG_PASSWORD (optional)

  • PG_DATABASE (optional)

  • RAILS_APP_SENTRY_DSN

  • VUE_APP_SENTRY_DSN

  • VUE_APP_INSTANCE

  • VUE_APP_CACHE_DOMAIN

  • SMTP_HOST

  • SMTP_PORT

  • SMTP_DOMAIN

  • SMTP_USERNAME

  • SMTP_PASSWORD

  • SMTP_FROM

  • SMTP_TO (for deployment notifications)

  • MA_ENDPOINT (optional)

  • MA_ENDPOINT_USER (optional)

  • MA_ENDPOINT_PASSWORD (optional)

  • MB_HOST (optional)

  • MB_USER (optional)

  • MB_PASSWORD (optional)

  • MB_DATABASE (optional)

  • HB_DATA_EXPIRES_IN (optional)

  • HB_SYNC_LIMIT (optional)

  • HB_SYNC_INTERVAL (optional)

  • HB_RECOMMENDATION_LIMIT (optional)

Releasing

Update the changelog and bump the version using the bin/version tool. Execute bin/version --help to see all parameters. Create a tag for the version and push it to Github. A Docker image will automatically be built and pushed to the registry.

bin/version version 1.0.0
git add lib/headbanger/version.rb web/package.json
git commit -m "Bump version to v1.0.0"
git tag v1.0.0
git push origin master
git push origin v1.0.0

Deployment

Initial deployment

# SSH into the server
ssh [email protected]

# Create a user
useradd -G ssh -G docker -m -s /bin/bash headbanger
su - headbanger

# Create SSH keypair
myserver$ mkdir ~/.ssh/
ssh-keygen -f ~/.ssh/headbanger-deployment-key -b 4096 -C "Headbanger deployment key"
cp ~/.ssh/headbanger-deployment-key.pub ~/.ssh/authorized_keys

# Initialize the database
docker exec -ti `docker ps -q name=postgres_postgres` psql -U postgres -c "CREATE ROLE headbanger WITH ENCRYPTED PASSWORD 'headbanger' LOGIN;"
docker exec -ti `docker ps -q name=postgres_postgres` psql -U postgres -c "CREATE DATABASE headbanger OWNER headbanger;"

# Logout, but don't forget to copy over the private key, and the host public key to your local machine
logout
logout

# Generate TLS client certificates for NGINX
openssl req -nodes -new -x509  -keyout ops/client.key -out ops/client.pem

Additionally, set DEPLOY_SSH_KEY, DEPLOY_SSH_HOST and DEPLOY_SSH_USER as Github Actions secrets.

Subsequent deployments

Ensure the images have been built and are available in the container registry. Apply your changes in ops/docker-compose.yml. Update the production tag to the correct commit and push it to Github The file will automatically be deployed, and the containers recreated.

nano ops/docker-compose.yml
git add ops/docker-compose.yml
git commit -m "Update images to latest version"
git tag -f production
git push origin master && git push -f origin production

License

See LICENSE.md.

headbanger's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar floriandejonckheere avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

sandy4321

headbanger's Issues

Your .dependabot/config.yml contained invalid details

Dependabot encountered the following error when parsing your .dependabot/config.yml:

The property '#/' did not contain a required property of 'update_configs'
The property '#/' contains additional properties ["updates"] outside of the schema when none are allowed
The property '#/version' value 2 did not match one of the following values: 1

Please update the config file to conform with Dependabot's specification using our docs and online validator.

Cannot migrate using Bolt protocol

The Neo4j database cannot be migrated using the Bolt protocol. Migrations over HTTP run fine.

rails aborted!
NoMethodError: undefined method `signature' for 46:Integer
/home/florian/.rvm/gems/ruby-2.4.0@headbanger/gems/neo4j-core-7.0.4/lib/neo4j/core/cypher_session/adaptors/bolt.rb:201:in `block in flush_messages'
/home/florian/.rvm/gems/ruby-2.4.0@headbanger/gems/neo4j-core-7.0.4/lib/neo4j/core/cypher_session/adaptors/bolt.rb:200:in `map'
/home/florian/.rvm/gems/ruby-2.4.0@headbanger/gems/neo4j-core-7.0.4/lib/neo4j/core/cypher_session/adaptors/bolt.rb:200:in `flush_messages'
/home/florian/.rvm/gems/ruby-2.4.0@headbanger/gems/neo4j-core-7.0.4/lib/neo4j/core/cypher_session/adaptors/bolt.rb:35:in `connect'
/home/florian/.rvm/gems/ruby-2.4.0@headbanger/gems/neo4j-core-7.0.4/lib/neo4j/core/cypher_session.rb:11:in `initialize'
/home/florian/.rvm/gems/ruby-2.4.0@headbanger/gems/neo4j-8.0.6/lib/neo4j/session_manager.rb:17:in `new'
/home/florian/.rvm/gems/ruby-2.4.0@headbanger/gems/neo4j-8.0.6/lib/neo4j/session_manager.rb:17:in `open_neo4j_session'
/home/florian/.rvm/gems/ruby-2.4.0@headbanger/gems/neo4j-8.0.6/lib/neo4j/railtie.rb:65:in `setup!'
/home/florian/.rvm/gems/ruby-2.4.0@headbanger/gems/neo4j-8.0.6/lib/neo4j/railtie.rb:51:in `block (2 levels) in <class:Railtie>'
/home/florian/.rvm/gems/ruby-2.4.0@headbanger/gems/neo4j-8.0.6/lib/neo4j/active_base.rb:18:in `establish_session'
/home/florian/.rvm/gems/ruby-2.4.0@headbanger/gems/neo4j-8.0.6/lib/neo4j/active_base.rb:8:in `current_session'
/home/florian/.rvm/gems/ruby-2.4.0@headbanger/gems/neo4j-8.0.6/lib/neo4j/shared.rb:17:in `neo4j_session'
/home/florian/.rvm/gems/ruby-2.4.0@headbanger/gems/neo4j-8.0.6/lib/neo4j/active_node/labels.rb:143:in `mapped_label'
/home/florian/.rvm/gems/ruby-2.4.0@headbanger/gems/neo4j-8.0.6/lib/neo4j/migrations/runner.rb:16:in `initialize'
/home/florian/.rvm/gems/ruby-2.4.0@headbanger/gems/neo4j-8.0.6/lib/neo4j/tasks/migration.rake:52:in `new'
/home/florian/.rvm/gems/ruby-2.4.0@headbanger/gems/neo4j-8.0.6/lib/neo4j/tasks/migration.rake:52:in `block (3 levels) in <top (required)>'
/home/florian/.rvm/gems/ruby-2.4.0@headbanger/gems/neo4j-8.0.6/lib/neo4j/tasks/migration.rake:46:in `block (2 levels) in <top (required)>'
/home/florian/.rvm/gems/ruby-2.4.0@headbanger/gems/railties-5.0.1/lib/rails/commands/rake_proxy.rb:14:in `block in run_rake_task'
/home/florian/.rvm/gems/ruby-2.4.0@headbanger/gems/railties-5.0.1/lib/rails/commands/rake_proxy.rb:11:in `run_rake_task'
/home/florian/.rvm/gems/ruby-2.4.0@headbanger/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:51:in `run_command!'
/home/florian/.rvm/gems/ruby-2.4.0@headbanger/gems/railties-5.0.1/lib/rails/commands.rb:18:in `<top (required)>'

Cache primary name

Add primary_name as an attribute, instead of querying the names association.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.