I will leave a memorandum on how to create an environment construction for Ruby on Rails as eco-friendly as possible (without polluting the environment).
Please let me know if there is a way to make it cleaner!
How To
mkdir sample-app && cd sample-app
bundle init
Gemfile
# frozen_string_literal: true
source "https://rubygems.org"
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
gem "rails"
bundle config set path 'vendor/bundle'
gem install bundler
bundle install
bundle exec rails new . -B -d mysql --skip-test
You can specify the database with -d, so change it accordingly.
When creating the API
bundle exec rails new . -B -d mysql --skip-test --api
Let's put it in API mode with --api
.
Then the Gemfile conflicts with the one originally created in init, but press Y to Overwrite.
bundle install
bundle config --local build.mysql2 "--with-cppflags=-I/usr/local/opt/openssl/include"
bundle config --local build.mysql2 "--with-ldflags=-L/usr/local/opt/openssl/lib"
See also: https://qiita.com/fukuda_fu/items/463a39406ce713396403
bundle exec rails webpacker:install
bundle exec rails db:create
Well, I feel that using Docker does not pollute the environment first ... I feel like I'm told How Dare You! Not using Docker, but I hope it will be helpful when building an environment locally without using Docker ~
Recommended Posts