Advertisement
Guest User

Untitled

a guest
Oct 11th, 2022
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. FROM alpine:latest
  2.  
  3. # Add all project stuff
  4. ADD ./main.py /
  5. ADD requirements.txt /
  6.  
  7. RUN mkdir /var/spool/cron/crontabs
  8.  
  9. # Add crontab file in the cron directory
  10. 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
  11.  
  12. # Create the log file to be able to run tail
  13. RUN touch /var/log/xxx-cron.log
  14.  
  15. # Install python and pip
  16. RUN apk add python3 py3-pip gcc python3-dev libc-dev tzdata bash
  17.  
  18. # Set timezone
  19. RUN cp /usr/share/zoneinfo/Europe/Warsaw /etc/localtime && echo "Europe/Warsaw" > /etc/timezone
  20. RUN apk del tzdata
  21.  
  22. # Install requirements with PIP
  23. RUN pip install -r /requirements.txt
  24.  
  25. # Run the command on container startup
  26. CMD [ "/usr/sbin/crond", "-u", "myuser", "-f", "-d8" ]
  27.  
  28.  
  29. RUN rm /bin/sh && ln -s /bin/bash /bin/sh
  30.  
  31. ### CIS Docker Bench Security
  32.  
  33. # 4.1 Ensure that a user for the container has been created (Automated)
  34.  
  35. RUN adduser \
  36. --disabled-password \
  37. --gecos "" \
  38. --home "/home/myuser" \
  39. --no-create-home \
  40. --uid "12345" \
  41. "myuser"
  42.  
  43. USER myuser
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement