Skip to content

Commit

Permalink
fix(docker): edit cron configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Couapy committed Apr 26, 2021
1 parent 711b67a commit eaa1e5b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
.vscode
docker-compose.yml
Dockerfile
LICENSE
logs
README.md
12 changes: 4 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
FROM python:3.9

# Install CRON
RUN apt update && apt install -yqq cron
COPY hello-cron /etc/cron.d/dynhostupdater
RUN chmod 0644 /etc/cron.d/dynhostupdater
RUN apt-get -qq update && apt-get install -yqq cron
COPY config/cron.conf /etc/cron.d/dynhostupdater
RUN chmod +x /etc/cron.d/dynhostupdater
RUN crontab /etc/cron.d/dynhostupdater

# Install application
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
RUN pip -q install -r requirements.txt
COPY . .

# Create default logs
RUN mkdir -p logs
RUN touch logs/lastest.log
6 changes: 4 additions & 2 deletions config/cron.conf
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
@reboot cd /app && python main.py > /dev/null 2>&1
*/15 * * * * root cd /app && python main.py > /dev/null 2>&1
PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin

@reboot root cd /app && python /app/main.py > /var/log/cron.log 2>&1
*/10 * * * * root cd /app && python /app/main.py > /dev/log/cron.log 2>&1
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ version: "3.9"

services:
dynhost:
image: .
command: cron -f
build: .
command: "cron -f"
volumes:
- logs:/app/logs
- ./logs:/app/logs

volumes:
logs:
Expand Down
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def update(self, current_ip: str) -> None:
self.logger.info('Successfully updated from %s to %s.' %
(self.old_ip, current_ip))
elif req.status_code == 401:
self.logger.error('Failed to update DNS. Wrong credentials.')
self.logger.error('Failed to update DNS. Bad credentials.')
else:
self.logger.error(
'Failed to update DNS. Unexpected error happened.')
Expand Down

0 comments on commit eaa1e5b

Please sign in to comment.