FROM ruby:2.6.3 RUN apt-get update -qq && apt-get install -y nodejs npm postgresql-client RUN mkdir /myapp WORKDIR /myapp COPY Gemfile /myapp/Gemfile COPY Gemfile.lock /myapp/Gemfile.lock COPY yarn.lock /myapp/yarn.lock RUN gem update --system RUN gem install bundler -v 2.0.1 RUN bundle install RUN npm install -g yarn COPY . /myapp RUN yarn install --check-file
# Add a script to be executed every time the container starts. COPY entrypoint.sh /usr/bin/ RUN chmod +x /usr/bin/entrypoint.sh ENTRYPOINT ["entrypoint.sh"] EXPOSE 3000
entrypoint.sh:
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 "$@"
# Host need to be set to work correctly with Docker host: <%= ENV['APP_DATABASE_HOSTNAME'] || 'localhost' %> username: postgres password: password pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
Username and password are required for Docker
With this setup it’s possible to run app with and without Docker