I made a rails environment in docker https://qiita.com/NA_simple/items/5e7f95ae58eec5d20e1f
If for some reason it doesn't work on the way, it seems that mysql-clients can't be installed. Refer to the URL below for how to rewrite. https://qiita.com/yagi_eng/items/1368fb2a234629a0c8e7
I'm addicted to it when I'm on the right track.
terminal
$ docker-compose run web rails db:create
Starting postgress_db ... done
Could not find activesupport-5.2.4.3 in any of the sources
Run `bundle install` to install missing gems.
Why is the ruby version different? ?? When I searched for the version in rbenv, I couldn't find 2.7.1. rbenv noticed old and updated
Update rbenv https://qiita.com/pugiemonn/items/f277440ec260b8d4fa6a
I noticed that the gem from was also old,
terminal
$ gem update
I haven't gone yet ... Perform bundler update.
I was desperate here and there, so I'll give it some time.
Organize once and start the procedure from the beginning of a different site.
https://toranoana-lab.hatenablog.com/entry/2020/06/05/173658
Start docker and access localhost without stopping! !! !! Alright! !! !! !!
localhost_3000
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Why: D It seems that there is no file when I google, so there are some articles that I forcibly make with sudo touch. But I deleted and created it thinking that there is a file
Same error.
?? ?? ?? I think, I notice that I have not launched mysql here This is it! !! !! I thought
terminal
mysql.server start
Is executed, but it does not start. Apparently when I google
terminal
sudo rm mysql.sock
brew uninstall mysql
brew install mysql
After deleting the sock file, uninstall mysql → install it. The path of mysql.sock was found in the previous error, so delete it
terminal
mysql.server start
... passed! !! !! !!
Did this go ...?
Yatter --------! !! !! !! !! !! !! !! !!
I think it was faster to build after understanding docker. Let's study again. myself.
Anyway, I'm glad I moved
Contents of each final file ↓
gemfile
source 'https://rubygems.org'
gem 'rails', '~>6'
docker-compose.yml
version: '3'
services:
db:
image: mysql:8.0
environment:
MYSQL_ROOT_PASSWORD:
ports:
- '3306:3306'
command: --default-authentication-plugin=mysql_native_password
volumes:
- mysql-data:/var/lib/mysql
web:
build: .
command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
volumes:
- .:/myapp
ports:
- "3000:3000"
depends_on:
- db
stdin_open: true
tty: true
command: bundle exec rails server -b 0.0.0.0
volumes:
mysql-data:
driver: local
Dockerfile
FROM ruby:2.7
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \
&& apt-get update -qq \
&& apt-get install -y nodejs yarn \
&& mkdir /myapp
WORKDIR /myapp
COPY Gemfile /myapp/Gemfile
COPY Gemfile.lock /myapp/Gemfile.lock
RUN bundle install
COPY . /myapp
COPY entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]
EXPOSE 3000
CMD ["rails", "server", "-b", "0.0.0.0"]
Recommended Posts