Cronjob added inside container

This commit is contained in:
2026-04-26 13:25:30 +02:00
parent a5aa6de67b
commit 2eaaf8d6d8
4 changed files with 36 additions and 8 deletions

View File

@@ -1,4 +1,4 @@
FROM ruby:2.7
FROM ruby:3.1
ENV BUILD_PACKAGES="apt-utils build-essential curl less nodejs sudo wget zsh libmariadb-dev libserialport-dev cron"
@@ -14,7 +14,18 @@ COPY Gemfile Gemfile.lock ./
RUN \
apt-get update -qq && \
apt-get install -y $BUILD_PACKAGES && \
bundle install
# Fix bundler version BEFORE bundle install
gem install bundler -v "$(grep -A 1 'BUNDLED WITH' Gemfile.lock | tail -n 1)" && \
bundle install && \
rm -rf /var/lib/apt/lists/*
# Copy cron file (if you use /etc/cron.d style)
COPY reportcron /etc/cron.d/reportcron
RUN chmod 0644 /etc/cron.d/reportcron && touch /var/log/cron.log
# Add entrypoint script
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
CMD ["/bin/bash -c ruby ./smartmeter.rb"]