Created
April 8, 2020 10:00
-
-
Save choyno/d525c16c399aab71389c3c287304a5dc to your computer and use it in GitHub Desktop.
Dockfile Rails 6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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