This repository has been archived by the owner on Jul 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added container for scheduled tasks
- Loading branch information
Showing
5 changed files
with
91 additions
and
9 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
FROM ruby:2.6.5 | ||
ARG MASTER_KEY=$MASTER_KEY | ||
|
||
# Add NodeJS repo | ||
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - | ||
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - | ||
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list | ||
|
||
# Install dependencies and remove unneeded packages/files | ||
RUN apt-get update -qq | ||
RUN apt-get install -y --no-install-recommends cron \ | ||
nodejs \ | ||
git \ | ||
unzip \ | ||
xvfb \ | ||
libxi6 \ | ||
libgconf-2-4 \ | ||
apt-transport-https \ | ||
yarn | ||
# Install packages | ||
WORKDIR /usr/src/app | ||
COPY Gemfile* /usr/src/app/ | ||
COPY Gemfile.lock* /usr/src/app/ | ||
RUN gem install bundler --no-document | ||
RUN bundle install --without development test | ||
|
||
# Setup app files | ||
COPY . /usr/src/app/ | ||
WORKDIR /usr/src/app | ||
COPY config/database.yml.example.production config/database.yml | ||
|
||
# Create log file and link to stdout | ||
RUN touch /var/log/cron.log | ||
|
||
# Add entrypoint | ||
COPY entrypoint-cron.sh /usr/bin/ | ||
RUN chmod +x /usr/bin/entrypoint-cron.sh | ||
ENTRYPOINT ["entrypoint-cron.sh"] | ||
|
||
# Update and cleanup container | ||
RUN apt-get upgrade -y && apt-get autoclean \ | ||
&& apt-get autoremove -y \ | ||
&& rm -rf /var/lib/apt \ | ||
/var/lib/dpkg \ | ||
/var/lib/cache \ | ||
/var/lib/log | ||
|
||
# App startup | ||
CMD ["cron", "-f"] |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# Update crontab file using whenever command | ||
bundle exec whenever --update-crontab | ||
|
||
# Follow the log file in the background | ||
tail -f /var/log/cron.log & | ||
|
||
# Then exec the container's main process (what's set as CMD in the Dockerfile). | ||
exec "$@" |