-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docker: create new container with cronjob tar-ing result daily
- Loading branch information
Showing
8 changed files
with
73 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,8 @@ services: | |
- 8080:8080 | ||
volumes: | ||
- persistent:/persistent:z | ||
env_file: | ||
- "files/.env" | ||
|
||
volumes: | ||
persistent: |
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,14 @@ | ||
FROM registry.fedoraproject.org/fedora:38 | ||
MAINTAINER [email protected] | ||
|
||
RUN dnf -y update | ||
RUN dnf -y install cronie tar | ||
|
||
RUN touch /var/log/cron.log | ||
|
||
COPY files/cron/tar_persistent.sh /bin/tar_persistent | ||
RUN chmod +x /bin/tar_persistent | ||
|
||
COPY files/cron/crontab_daily /etc/cron.d/crontab_daily | ||
RUN chmod +x /etc/cron.d/crontab_daily | ||
RUN crontab /etc/cron.d/crontab_daily |
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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
FROM registry.fedoraproject.org/fedora:38 | ||
MAINTAINER [email protected] | ||
|
||
ENV FEEDBACK_DIR=/persistent/results | ||
ENV ENV=production | ||
|
||
RUN dnf -y update && \ | ||
|
@@ -19,6 +18,8 @@ RUN dnf -y update && \ | |
sudo \ | ||
python3-ipdb \ | ||
findutils \ | ||
cronie \ | ||
tar \ | ||
# Frontend | ||
&& dnf -y install \ | ||
npm \ | ||
|
@@ -36,7 +37,6 @@ RUN npx shadow-cljs release app | |
FROM registry.fedoraproject.org/fedora:38 | ||
MAINTAINER [email protected] | ||
|
||
ENV FEEDBACK_DIR=/persistent/results | ||
ENV ENV=production | ||
|
||
RUN dnf -y install python3-fastapi \ | ||
|
@@ -52,8 +52,17 @@ RUN dnf -y install python3-fastapi \ | |
COPY --from=0 /src/frontend/public /src/frontend/public | ||
COPY --from=0 /src/backend /src/backend | ||
|
||
# According to the documentation, gunicorn is a valid production server | ||
# https://www.uvicorn.org/deployment/ | ||
# set-up cron | ||
RUN touch /var/log/cron.log | ||
|
||
COPY files/cron/tar_persistent.sh /bin/tar_persistent | ||
RUN chmod +x /bin/tar_persistent | ||
|
||
COPY files/cron/crontab_daily /etc/cron.d/crontab_daily | ||
RUN chmod +x /etc/cron.d/crontab_daily | ||
RUN crontab /etc/cron.d/crontab_daily | ||
|
||
|
||
WORKDIR /src/backend | ||
ENV PYTHONPATH="${PYTHONPATH}:/src" | ||
|
||
|
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,12 @@ | ||
#!/bin/bash | ||
|
||
set -m | ||
|
||
# According to the documentation, gunicorn is a valid production server | ||
# https://www.uvicorn.org/deployment/ | ||
# TODO: We should put this into a config file | ||
gunicorn -k uvicorn.workers.UvicornWorker --certfile /persistent/letsencrypt/live/log-detective.com/cert.pem --keyfile /persistent/letsencrypt/live/log-detective.com/privkey.pem --ca-certs /persistent/letsencrypt/live/log-detective.com/fullchain.pem api:app -b 0.0.0.0:8080 | ||
|
||
crond -f & | ||
|
||
fg %1 |
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,5 @@ | ||
SHELL=/bin/bash | ||
PATH=/sbin:/bin:/usr/sbin:/usr/bin | ||
|
||
# run every day at 1:05AM | ||
5 1 * * * root tar_persistent >> /var/log/cron.log 2>&1 |
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,7 @@ | ||
#!/usr/bin/sh | ||
|
||
# archive results tar_persistent.sh and remove the old ones | ||
FILE_NAME=data-$(date +%s).tar.gz | ||
tar -czvf $STORAGE_DIR/new-$FILE_NAME -C $FEEDBACK_DIR . && \ | ||
rm -f $STORAGE_DIR/data-*.tar.gz && \ | ||
mv $STORAGE_DIR/new-$FILE_NAME $STORAGE_DIR/$FILE_NAME |
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,2 @@ | ||
STORAGE_DIR=/persistent | ||
FEEDBACK_DIR=/persistent/results |