FROM ruby:2.6.6# タイムゾーンの設定ENVTZ='Asia/Tokyo'RUN apt-get update -qq \
&& apt-get install -y nodejs postgresql-client \
# 日本語をDocker内で使えるようにする&& apt-get install -y locales \
&& locale-gen C.UTF-8 \
&&echo"export LANG=C.UTF-8" >> ~/.bashrcRUN mkdir /myappWORKDIR /myapp COPY Gemfile /myapp/GemfileCOPY Gemfile.lock /myapp/Gemfile.lockRUN bundle installCOPY . /myapp# Add a script to be executed every time the container starts.COPY entrypoint.sh /usr/bin/RUN chmod +x /usr/bin/entrypoint.shENTRYPOINT["entrypoint.sh"]EXPOSE 3000# Start the main process.CMD["rails","server","-b","0.0.0.0"]
1
2
3
4
5
6
7
8
#!/bin/bash
set -e
# Remove a potentially pre-existing server.pid for Rails.rm -f /myapp/tmp/pids/server.pid
# Then exec the container's main process (what's set as CMD in the Dockerfile).exec"$@"
$ docker-compose build
$ docker-compose up -d
$ docker-compose run web rails db:create
$ docker-compose run web rails db:migrate
$ docker-compose run web rails db:seed