Musik88
Hey 👋
Welcome to this awesome project. Since you're here, I assume you love music like I do. So, turn it up!
Tech stack
This is a Ruby on Rails 6 application with several dependencies.
- Sidekiq for background job.
- Redis for in-memory database. This one is only used by the Sidekiq for now.
- PostgreSQL for the database.
- Yarn for the frontend.
- yt-dlp to download youtube to audio.
yt-dlp needs the ffmpeg:
Make sure you have the latest version for yt-dlp: sudo yt-dlp -U
After that you can solve this problem by installing the missing ffmpeg.
Ubuntu and debian: sudo apt-get install ffmpeg
macOS: brew install ffmpeg
Windows: choco install ffmpeg ```
Several recommendation to running this project in one's development machine:
- Recommended ruby version mamager is
rbenv. - Use Ruby in the
.ruby-versionfile. - Progress.app client is recommended.
- Use
nvmto manage your Node version. Use Node version in the.nvmrcfile. - User Postbird app to manage your PostgreSQL.
- Use
mkcertfor local certificates.
Sidekiq
We use Sidekiq for background task management. Run local sidekiq: bundle exec sidekiq
Running local development
- Clone the app.
- Install Ruby with the
rbenv. - Run
bundle install. - Copy the
master.keyfile from the server. Make sure you've uploaded your key so you can ssh to the box.bash scp deploy@musik88.com:apps/musik88-web/config/master.key config/master.key - Create a
musik88_com_developmentdatabase. - Run
rails db:migrate. - Run
yarn install. - Run
rails s.
Database
- Dump db from production with the command from the ssh server: pg_dump -h localhost -U dbuser -Fc dbname > dbname.dump
- Download the dump file: scp deploy@musik88.com:apps/path-to-dump-file.dump
- Import to your local db: pg_restore -c -d musik88_com_development musik88_com_production.dump
There's a known issue with the db production and development about the meta table. If one's copy the db content from production, update the local schema migration table by adding a new row with the content from the schema.rb
Issues found
Fix libv8
- bundle config build.libv8 --with-system-v8 gem install pg -v '1.2.3' -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/14/bin/pg_config
Mac M1 Chip
Avoid opening your terminal using Rosetta, it will make things messier.
rbenv 3.0.2 Mac M1
$ export SDKROOT="$(xcrun -show-sdk-path -sdk macosx)" # because the /usr/bin/clang shim automatically set it
$ export RUBY_CONFIGURE_OPTS="CC=$(xcrun -f clang)"
$ rbenv install 3.1.3
Issue with openssl
OPENSSL_CFLAGS=-Wno-error=implicit-function-declaration RUBY_CONFIGURE_OPTS=--with-readline-dir="$(brew --prefix readline)" rbenv install 3.0.6 --verbose
Use local .env file
Provide sets of environment variables to run this app locally.
Application documentation
Follow me
This feature based on the infamous Michael Hart RoR tutorials: https://3rd-edition.railstutorial.org/book/following_users
JWT
https://enlear.academy/how-to-create-a-rails-6-api-with-devise-jwt-46fa35085e85 https://tergell.medium.com/rails-devise-jwt-tutorial-b5d5b03d9040
Mailers
During the development, any mailer wil be handled by the letter_opener gem. To preview emails, visit https://localhost:3001/rails/mailers/ during development.
Test
Run test
bundle exec rake test