Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update functionality - Major update #2

Merged
merged 12 commits into from
Aug 18, 2024
34 changes: 34 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,35 @@
# Include any files or directories that you don't want to be copied to your
# container here (e.g., local build artifacts, temporary files, etc.).
#
# For more help, visit the .dockerignore file reference guide at
# https://docs.docker.com/go/build-context-dockerignore/

.env
**/.DS_Store
**/__pycache__
**/.venv
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/bin
**/charts
**/docker-compose*
**/compose.y*ml
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
28 changes: 26 additions & 2 deletions .github/workflows/pylint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,24 @@ on:
workflow_dispatch:
push:
pull_request:

env:
CF_ZONE_ID: ${{ secrets.CF_ZONE_ID }}
CF_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
DNS_RECORD_COMMENT_KEY: ${{ secrets.DNS_RECORD_COMMENT_KEY }}
DOMAINS_FILE_PATH: ${{ secrets.DOMAINS_FILE_PATH }}
DOMAINS: ${{ secrets.DOMAINS }}
SCHEDULE_MINUTES: "5"
TTL: "1"
PROXIED: "True"
TYPE: "A"
UPDATE_TYPE: "False"
UPDATE_PROXY: "False"
UPDATE_TTL: "False"

jobs:
build:
name: Run tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -17,8 +32,17 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pylint
pip install pylint pytest pytest-md pytest-emoji
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Analysing the code with pylint
run: |
pylint $(git ls-files '*.py')
pylint $(git ls-files '*.py')
- name: Run pytest
uses: pavelzw/[email protected]
with:
verbose: true
emoji: true
job-summary: true
custom-arguments: 'functions.py -q'
click-to-expand: true
report-title: 'Test Report'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dns_updater.log
scripts/*
.vscode/
__pycache__/
21 changes: 18 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
FROM python:3.11-slim
# syntax=docker/dockerfile:1
FROM python:alpine

# Prevents Python from writing pyc files.
ENV PYTHONDONTWRITEBYTECODE=1

# Keeps Python from buffering stdout and stderr to avoid situations where
# the application crashes without emitting any logs due to buffering.
ENV PYTHONUNBUFFERED=1

WORKDIR /app

# Copy relevant files into the container
COPY main.py /app
COPY functions.py /app
COPY requirements.txt /app
COPY domains.json /app

RUN pip install --no-cache-dir requests schedule
RUN --mount=type=cache,target=/root/.cache/pip \
--mount=type=bind,source=requirements.txt,target=requirements.txt \
python -m pip install -r requirements.txt

CMD ["python", "main.py"]
# Run the application.
CMD ["python", "main.py"]
40 changes: 32 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,33 @@
#Docker compose for cloudflare-dns-updater
version: "3.6"
services:
dns-updater:
# Uncomment this to use an image instead of building locally
# image: your-image-tag
# Uncomment this to build locally
build: .
env_file:
- .env

cloudlfare-dns-updater:
image: "cloudflare-dns-updater:latest"
container_name: "cloudlfare-dns-updater"
volumes:
- app-data:/app # optional unless using the domains.json file and DOMAINS_FILE_PATH variable
environment:
CF_API_TOKEN: "YOUR_API_TOKEN" # Recomended to create a token for the zones, not use the main token
CF_ZONE_ID: "YOUR_ZONE_ID1,YOUR_ZONE_ID2" # Can be only 1 zone ID (usually is)
# Choose the method in which you get your domain records:
# You must choose one method
# DOMAINS_FILE_PATH is not needed if the DOMAINS or DNS_RECORD_COMMENT_KEY variables are set.
# Edit the domains.json according to the example file in the mounted volume.
# If you don't mount a volume, you cannot use the domains.json file and DOMAINS_FILE_PATH variable.

DNS_RECORD_COMMENT_KEY: "Comm1,Comm2" # Any DNS reccord that has any of the comments specified here. Can be 1 comment
# DOMAINS: "domain.com,example1.domain.com,example2.domain.com"
# DOMAINS_FILE_PATH: .\domains.json
SCHEDULE_MINUTES: 5
PROXIED: True # if proxied is set to True, TTL cannot be set/changed
TYPE: A # Supports either A, AAA or CNAME
TTL: 1
restart: "unless-stopped"

volumes:
app-data:
driver: local
driver_opts:
o: bind
type: none
device: /volume1/docker/cloudflare-dns-updater
Loading