-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
37 lines (28 loc) · 1.14 KB
/
Dockerfile
File metadata and controls
37 lines (28 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Use an official R image as the base image
FROM rocker/r-ver:4.4.3
# Add a label to the Dockerfile for auto tagging of builds
LABEL version="1.1.5" \
description="GitHub Organization backup code"
# Copy your R script to the container
COPY . /archiving_code
# Install dependencies
RUN apt-get update && apt-get install -y \
cron \
libcurl4-openssl-dev \
libssl-dev \
libxml2-dev \
git \
pandoc \
&& rm -rf /var/lib/apt/lists/*
# Bootstrap renv
RUN R -e "install.packages('renv'); renv::restore('archiving_code')"
# Set up a cron job to run the R scripts every Sunday
RUN touch /var/log/cron.log \
&& chmod 666 /var/log/cron.log \
&& echo "PATH=/usr/local/bin:/usr/bin:/bin" > cron_jobs_script \
&& echo "0 0 1 * * Rscript /archiving_code/backup_all_repos.R >> /var/log/cron.log 2>&1" >> cron_jobs_script \
&& echo "0 0 1 * * Rscript /archiving_code/remove_old_backups.R >> /var/log/cron.log 2>&1" >> cron_jobs_script \
&& crontab cron_jobs_script \
&& rm cron_jobs_script
# Ensure the cron service runs when the container starts
CMD ["sh", "-c", "printenv > /etc/environment && cron && tail -f /var/log/cron.log"]