Rainy Days is a blog app by Ruby on Rails and Vue.js, and is a portfolio app to showcase how I code.
Rainy Days is a revised version of Dainy Day Blog. The app had improvements, adjustments to run on newer version of Rails, and a new feature to dockerize.
On calm rainy days, surrounded by soft sound of pouring rain and feeling fresh air, people might enjoy blogging. This is why the app is named like so.
Install below:
Setup OAuth 2 login:
Create your own app at Google, GitHub, and GitLab for OAuth2 authentication.
For reference, URL(s) are listed below, but it's good to research by your own.
The ways of setup OAuth login are very different in each identity provider.
It might be confusing, so you'd better to look at multiple explanations.
Once the apps are created, get client id and client secret combinations.
Clone the repo:
$ git clone [email protected]:yokolet/rainy-days.git
$ cd rainy-days
$ bundle install
$ rails db:prepare
$ bun install
Create credentials for three environments as in below:
$ rm config/master.key
$ rm config/credentials.yml.enc
$ EDITOR=vim rails credentials:edit --environment development
$ EDITOR=vim rails credentials:edit --environment test
$ EDITOR=vim rails credentials:edit --environment production
Each credentials files should have values below:
secret_key_base: YOUR_SECRET_KEY_BASE
# OAuth
oauth:
google:
redirect_uri: REDIRECT_URI_FOR_GOOGLE
client_id: YOUR_GOOGLE_CLIENT_ID
client_secret: YOUR_GOOGLE_CLIENT_SECRET
github:
redirect_uri: REDIRECT_URI_FOR_GITHUB
client_id: YOUR_GITHUB_CLIENT_ID
client_secret: YOUR_CLIENT_SECRET
gitlab:
redirect_uri: REDIRECT_URI_FOR_GITLAB
client_id: YOUR_GITLAB_CLIENT_ID
client_secret: YOUR_GITLAB_CIENT_SECRET
To generate the secret_key_base value, try below:
$ bin/rails secret
Then, copy & paste the value to credentials file.
This command starts Rails and vite servers in development environment. Both frontend and backend changes are reloaded and reflected to a web page.
$ bin/dev
Once, the servers start successfully, go to http://localhost:3906
When the app runs without SSL in production environment,
set two config parameters to false in config/environments/production.rb
:
config.assume_ssl = false
config.force_ssl = false
Then, precompile assets:
$ RAILS_ENV=production bin/rails assets:precompile
Start the app as in below:
$ RAILS_ENV=production bin/rails s -p 3906
If you change the port number:
Create .env
file with the content below:
DB_HOST=db
DB_USERNAME=postgres
DB_PASSWORD=postgres
Create a docker image:
RAILS_MASTER_KEY=`cat config/credentials/production.key` docker compose up --build
Once the docker image is created, the app starts running. Go to http://localhost:3906
$ bundle exec rspec
The application is live at Render: