feature/share-libs
md 116 lines 3.36 KB
Rendered Raw
1 # Musik88
2
3 Hey 👋
4
5 Welcome to this awesome project. Since you're here, I assume you love music like I do. So, turn it up!
6
7 ## Tech stack
8
9 This is a `Ruby on Rails` 6 application with several dependencies.
10
11 1. Sidekiq for background job.
12 2. Redis for in-memory database. This one is only used by the Sidekiq for now.
13 3. PostgreSQL for the database.
14 4. Yarn for the frontend.
15 5. yt-dlp to download youtube to audio.
16
17 `yt-dlp` needs the `ffmpeg`:
18
19 Make sure you have the latest version for yt-dlp:
20 sudo yt-dlp -U
21
22 After that you can solve this problem by installing the missing ffmpeg.
23
24 Ubuntu and debian:
25 sudo apt-get install ffmpeg
26
27 macOS:
28 brew install ffmpeg
29
30 Windows:
31 choco install ffmpeg
32 ```
33
34 Several recommendation to running this project in one's development machine:
35
36 1. Recommended ruby version mamager is `rbenv`.
37 2. Use Ruby in the `.ruby-version` file.
38 3. Progress.app client is recommended.
39 4. Use `nvm` to manage your Node version. Use Node version in the `.nvmrc` file.
40 5. User Postbird app to manage your PostgreSQL.
41 6. Use `mkcert` for local certificates.
42
43 ## Sidekiq
44
45 We use Sidekiq for background task management. Run local sidekiq: `bundle exec sidekiq`
46
47 ## Running local development
48
49 1. Clone the app.
50 2. Install Ruby with the `rbenv`.
51 3. Run `bundle install`.
52 4. Copy the `master.key` file from the server. Make sure you've uploaded your key so you can ssh to the box.
53 ```bash
54 scp deploy@musik88.com:apps/musik88-web/config/master.key config/master.key
55 ```
56 5. Create a `musik88_com_development` database.
57 6. Run `rails db:migrate`.
58 7. Run `yarn install`.
59 8. Run `rails s`.
60
61 ### Database
62
63 1. Dump db from production with the command from the ssh server: pg_dump -h localhost -U dbuser -Fc dbname > dbname.dump
64 2. Download the dump file: scp deploy@musik88.com:apps/path-to-dump-file.dump
65 3. Import to your local db: pg_restore -c -d musik88_com_development musik88_com_production.dump
66
67 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
68
69 ## Issues found
70
71 Fix libv8
72
73 1. bundle config build.libv8 --with-system-v8
74 gem install pg -v '1.2.3' -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/14/bin/pg_config
75
76
77 ### Mac M1 Chip
78
79 Avoid opening your terminal using Rosetta, it will make things messier.
80
81 rbenv 3.0.2 Mac M1
82
83 ```bash
84 $ export SDKROOT="$(xcrun -show-sdk-path -sdk macosx)" # because the /usr/bin/clang shim automatically set it
85 $ export RUBY_CONFIGURE_OPTS="CC=$(xcrun -f clang)"
86 $ rbenv install 3.1.3
87 ```
88
89 # Issue with openssl
90 OPENSSL_CFLAGS=-Wno-error=implicit-function-declaration RUBY_CONFIGURE_OPTS=--with-readline-dir="$(brew --prefix readline)" rbenv install 3.0.6 --verbose
91
92 ## Use local `.env` file
93 Provide sets of environment variables to run this app locally.
94
95
96 ## Application documentation
97
98 ### Follow me
99
100 This feature based on the infamous Michael Hart RoR tutorials: https://3rd-edition.railstutorial.org/book/following_users
101
102 ### JWT
103
104
105 https://enlear.academy/how-to-create-a-rails-6-api-with-devise-jwt-46fa35085e85
106 https://tergell.medium.com/rails-devise-jwt-tutorial-b5d5b03d9040
107
108 ### Mailers
109
110 During the development, any mailer wil be handled by the `letter_opener` gem. To preview emails, visit `https://localhost:3001/rails/mailers/` during development.
111
112 ## Test
113
114 ### Run test
115
116 bundle exec rake test