docker sculated time

This commit is contained in:
Parsa Nazer
2025-02-24 23:35:42 +03:30
parent 464cb1f550
commit 6c68d3f4b8
4 changed files with 22 additions and 5 deletions
+2
View File
@@ -1,4 +1,6 @@
#!/bin/sh #!/bin/sh
. /etc/profile
echo "Cron job triggered at $(date)" >> /var/log/cron/cron.log
echo 'started the backup' echo 'started the backup'
export PGPASSWORD=$PG_PASSWORD export PGPASSWORD=$PG_PASSWORD
+6 -1
View File
@@ -1 +1,6 @@
* * * * * /app/backup.sh # Add this line for environment variables
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# Schedule (runs every minute for testing)
* * * * * /app/backup.sh >> /var/log/cron/cron.log 2>&1
+13 -3
View File
@@ -1,6 +1,16 @@
FROM alpine:3.19 FROM alpine:3.19
RUN apk add --no-cache postgresql-client curl zip tzdata
RUN apk add --no-cache postgresql-client curl zip tzdata cron
RUN ln -sf /usr/share/zoneinfo/UTC /etc/localtime
RUN mkdir -p /var/log/cron
WORKDIR /app WORKDIR /app
COPY backup.sh . COPY backup.sh .
RUN chmod +x backup.sh COPY crontab /etc/crontabs/root
CMD ["/app/backup.sh"]
RUN chmod +x backup.sh && \
chmod 0644 /etc/crontabs/root && \
touch /var/log/cron/cron.log
CMD ["sh", "-c", "crond -l 8 -L /var/log/cron/cron.log -f"]
+1 -1
View File
@@ -52,7 +52,7 @@ services:
- PG_PORT=5432 - PG_PORT=5432
- PG_DATABASE=hshop - PG_DATABASE=hshop
- PG_USER=byeto - PG_USER=byeto
- PG_PASSWORD=vuhbyq-cypMu0-sirbon # Remove single quotes here - PG_PASSWORD=vuhbyq-cypMu0-sirbon
- TELEGRAM_BOT_TOKEN=7068288679:AAGecMnyt9A6R78OQu8nQeISMK1LepX718g - TELEGRAM_BOT_TOKEN=7068288679:AAGecMnyt9A6R78OQu8nQeISMK1LepX718g
- TELEGRAM_CHAT_ID=1198382521 - TELEGRAM_CHAT_ID=1198382521
volumes: volumes: