Skip to content

Commit 4b98982

Browse files
Merge pull request #1 from Joren-vanGoethem/python
2 parents 5760893 + d50929b commit 4b98982

15 files changed

+263
-50
lines changed

.env.example

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CF_EMAIL=example@hotmail.com
2+
CF_RECORD_TYPE=A
3+
CF_TTL=120
4+
CF_PROXIED=false
5+
CF_API_KEY=nice_try
6+
CF_ZONE_ID=nope
7+
CF_RECORD_ID=sike
8+
CF_RECORD_NAME=domain.com
9+
CF_RECORD_TYPE=A
10+
CF_TTL=120
11+
CF_PROXIED=false

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.env
2+
.idea

.idea/.gitignore

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/cloudflare-dns-updater.iml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/profiles_settings.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Dockerfile

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
1-
FROM alpine:latest
1+
# Use an official Python runtime as a parent image
2+
FROM python:3.12-slim
23

3-
# Install packages
4-
RUN apk --no-cache add curl bash
4+
# Install cron
5+
RUN apt-get update && apt-get install -y cron && rm -rf /var/lib/apt/lists/*
56

6-
# Set default cron timer to 5 minutes
7-
ENV CRON_TIMER="*/5 * * * *"
7+
# Set the working directory
8+
WORKDIR /app
89

9-
# Copy the update script to the container
10-
COPY cloudflare-updater.sh /usr/local/bin/update-dns.sh
10+
# Copy the Python script and requirements
11+
COPY requirements.txt .
12+
COPY cloudflare_updater.py .
1113

12-
# Make the script executable
13-
RUN chmod +x /usr/local/bin/update-dns.sh
14+
# Install dependencies
15+
RUN pip install --no-cache-dir -r requirements.txt
1416

15-
# Set the script to run based on the CRON_TIMER environment variable
16-
RUN echo "$CRON_TIMER /usr/local/bin/update-dns.sh" > /etc/crontabs/root
17+
# Copy and set up the entrypoint script
18+
COPY cronjob.sh .
19+
RUN chmod +x cronjob.sh
1720

18-
# Start cron job in the foreground
19-
CMD ["crond", "-f"]
21+
# Create the log file to be able to run tail
22+
RUN touch /var/log/cron.log
23+
24+
# Set the entrypoint
25+
ENTRYPOINT ["./cronjob.sh"]

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Cloudflare DNS Updater
22

3-
This Docker container automatically updates your Cloudflare DNS records with your current IP address. It's ideal for non-static IP setups like normal residential connections where your IP changes frequently, and you want to keep your domain updated on Cloudflare.
3+
This Docker container automatically updates your Cloudflare DNS records with your current IP address. It's ideal for
4+
non-static IP setups like normal residential connections where your IP changes frequently, and you want to keep your
5+
domain updated on Cloudflare.
46

57
## Features
68

@@ -35,8 +37,6 @@ Configure the container with the following environment variables:
3537
Here's an example `docker-compose.yml` file that sets up the Cloudflare DNS updater:
3638

3739
```yaml
38-
version: '3.8'
39-
4040
services:
4141
cloudflare-dns-updater:
4242
image: your-dockerhub-username/cloudflare-dns-updater:latest
@@ -80,8 +80,6 @@ services:
8080
To manage multiple domains or DNS records, you can extend your `docker-compose.yml` to include additional services:
8181

8282
```yaml
83-
version: '3.8'
84-
8583
services:
8684
domain1-updater:
8785
image: your-dockerhub-username/cloudflare-dns-updater:latest
@@ -114,8 +112,10 @@ services:
114112
115113
### Notes
116114
117-
- **Security**: Ensure your API keys and other sensitive information are stored securely and not exposed in public repositories.
118-
- **Cron Schedule**: The script runs every 5 minutes by default. You can modify this in the `Dockerfile` or by creating a custom container with your preferred schedule.
115+
- **Security**: Ensure your API keys and other sensitive information are stored securely and not exposed in public
116+
repositories.
117+
- **Cron Schedule**: The script runs every 5 minutes by default. You can modify this in the `Dockerfile` or by creating
118+
a custom container with your preferred schedule.
119119

120120
### Troubleshooting
121121

0 commit comments

Comments
 (0)