2018-05-19 13:53:47 +00:00
|
|
|
# Rails Whenever Dockerfile Demo
|
|
|
|
|
|
|
|
- [Simple whenever cron job](config/schedule.rb):
|
2018-05-19 13:56:05 +00:00
|
|
|
|
2018-05-19 13:53:47 +00:00
|
|
|
```
|
|
|
|
every 1.minute do
|
|
|
|
command "echo Hello >> /app/log/cron.log"
|
|
|
|
end
|
|
|
|
```
|
|
|
|
- [Dockerfile](Dockerfile.) :
|
2018-05-19 13:56:05 +00:00
|
|
|
|
2018-05-19 13:53:47 +00:00
|
|
|
```dockerfile
|
|
|
|
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](images/capture.png)
|