Skip to content

Instantly share code, notes, and snippets.

@choyno
Created April 8, 2020 10:00
Show Gist options
  • Save choyno/d525c16c399aab71389c3c287304a5dc to your computer and use it in GitHub Desktop.
Save choyno/d525c16c399aab71389c3c287304a5dc to your computer and use it in GitHub Desktop.
Dockfile Rails 6
version: '3'
services:
web:
build: .
command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0' && bundle exec clockwork ./config/clock.rb"
volumes:
- .:/wfh-tracker
ports:
- "3000:3000"
environment:
- RAILS_ENV=development
FROM ruby:2.6.0
RUN printf "deb http://archive.debian.org/debian/ jessie main\ndeb-src http://archive.debian.org/debian/ jessie main\ndeb http://security.debian.org jessie/updates main\ndeb-src http://security.debian.org jessie/updates main" > /etc/apt/sources.list
RUN apt-get update -qq && apt-get install -y nodejs
ENV APP_PATH=/wfh-tracker
RUN mkdir $APP_PATH
WORKDIR $APP_PATH
COPY Gemfile "${APP_PATH}/Gemfile"
COPY Gemfile.lock "${APP_PATH}/Gemfile.lock"
RUN bundle install
COPY . /app
# Add a script to be executed every time the container starts.COPY entrypoint.sh /usr/bin/
COPY entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]
EXPOSE 3000
# Start the main process.
# Keep reading to see why we commented this line out!
CMD ["rails", "server", "-b", "0.0.0.0"]
#!/bin/bash
set -e
# Remove a potentially pre-existing server.pid for Rails.
rm -f /app/tmp/pids/server.pid
# Then exec the container's main process (what's set as CMD in the Dockerfile).
exec "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment