Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- FROM alpine:latest
- # Add all project stuff
- ADD ./main.py /
- ADD requirements.txt /
- RUN mkdir /var/spool/cron/crontabs
- # Add crontab file in the cron directory
- RUN echo '0 8-16 * * 1-5 echo Starting xxx at $(date) >> /var/log/xxx-cron.log; python3 /main.py >> /var/log/xxx-cron.log 2>&1; echo Exitcode of script is $? >> /var/log/xxx-cron.log \n' >> /etc/crontabs/root
- # Create the log file to be able to run tail
- RUN touch /var/log/xxx-cron.log
- # Install python and pip
- RUN apk add python3 py3-pip gcc python3-dev libc-dev tzdata bash
- # Set timezone
- RUN cp /usr/share/zoneinfo/Europe/Warsaw /etc/localtime && echo "Europe/Warsaw" > /etc/timezone
- RUN apk del tzdata
- # Install requirements with PIP
- RUN pip install -r /requirements.txt
- # Run the command on container startup
- CMD [ "/usr/sbin/crond", "-u", "myuser", "-f", "-d8" ]
- RUN rm /bin/sh && ln -s /bin/bash /bin/sh
- ### CIS Docker Bench Security
- # 4.1 Ensure that a user for the container has been created (Automated)
- RUN adduser \
- --disabled-password \
- --gecos "" \
- --home "/home/myuser" \
- --no-create-home \
- --uid "12345" \
- "myuser"
- USER myuser
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement