Go to file
2018-05-19 15:53:47 +02:00
.idea Init 2018-05-19 15:53:47 +02:00
app Init 2018-05-19 15:53:47 +02:00
bin Init 2018-05-19 15:53:47 +02:00
config Init 2018-05-19 15:53:47 +02:00
db Init 2018-05-19 15:53:47 +02:00
images Init 2018-05-19 15:53:47 +02:00
lib/tasks Init 2018-05-19 15:53:47 +02:00
log Init 2018-05-19 15:53:47 +02:00
public Init 2018-05-19 15:53:47 +02:00
tmp Init 2018-05-19 15:53:47 +02:00
vendor Init 2018-05-19 15:53:47 +02:00
.gitignore Init 2018-05-19 15:53:47 +02:00
.ruby-version Init 2018-05-19 15:53:47 +02:00
config.ru Init 2018-05-19 15:53:47 +02:00
Dockerfile. Init 2018-05-19 15:53:47 +02:00
Gemfile Init 2018-05-19 15:53:47 +02:00
Gemfile.lock Init 2018-05-19 15:53:47 +02:00
RailsTest.iml Init 2018-05-19 15:53:47 +02:00
Rakefile Init 2018-05-19 15:53:47 +02:00
README.md Init 2018-05-19 15:53:47 +02:00

Rails Whenever Dockerfile Demo

every 1.minute do
  command "echo Hello >> /app/log/cron.log"
end
FROM ruby:2.5

RUN apt-get update && \
    apt-get install -y cron && \
    rm -rf /var/lib/apt/lists/*

ENV LANG C.UTF-8
ENV RAILS_ENV production
ENV INSTALL_PATH /app

RUN mkdir $INSTALL_PATH && \
    mkdir log && touch /log/cron.log

ADD Gemfile Gemfile.lock ./

WORKDIR $INSTALL_PATH

RUN bundle install
COPY . .
RUN bundle exec whenever --update-crontab
CMD cron && rails server -e $stdout.sync=true

Container's Bash Result :

Container's terminal