From f0a2b9589708c85baa5359a7e9acbae20720dc1c Mon Sep 17 00:00:00 2001 From: bakerboy448 <55419169+bakerboy448@users.noreply.github.com> Date: Fri, 26 Apr 2024 16:44:38 -0500 Subject: [PATCH] misc changes - add listen on host var - rename host and port vars - expose default port in docker file - fix compose oopsies --- DOCKERFILE | 9 ++++++--- autodns.py | 7 ++++--- docker-compose.example.yml | 8 +++----- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/DOCKERFILE b/DOCKERFILE index 4596f00..12d0e03 100644 --- a/DOCKERFILE +++ b/DOCKERFILE @@ -10,6 +10,9 @@ ENV PYTHONDONTWRITEBYTECODE=1 # Set Python stdout and stderr streams to be unbuffered ENV PYTHONUNBUFFERED=1 +# Set Flask application port +ENV FLASK_RUN_PORT=4295 + # Install system dependencies RUN apt-get update \ && apt-get install -y --no-install-recommends gcc libffi-dev \ @@ -25,12 +28,12 @@ COPY requirements.txt . # Install Python dependencies RUN pip install --no-cache-dir -r requirements.txt -# Copy the rest of the application -COPY . . - # Specify non-root user to run the app RUN useradd -m myuser USER myuser +# Expose the port the app runs on +EXPOSE 4295 + # Command to run the application CMD ["python", "./autodns.py"] diff --git a/autodns.py b/autodns.py index bcf8ce6..2f70105 100644 --- a/autodns.py +++ b/autodns.py @@ -152,8 +152,9 @@ def main(): if hasattr(args, 'func'): args.func(args) else: - # If no CLI command is provided, run the Flask app # Use the FLASK_RUN_PORT environment variable or default to port 5000 - port = int(os.getenv("FLASK_RUN_PORT", "5000")) - app.run(host="0.0.0.0", port=port) + # Run autodns daemon by default + port = int(os.getenv("AUTODNS_PORT", "5000")) + listen_on = os.getenv("AUTODNS_HOST", "0.0.0.0") + app.run(host=listen_on, port=port) if name == "main": main() diff --git a/docker-compose.example.yml b/docker-compose.example.yml index 295782a..7ce9e48 100644 --- a/docker-compose.example.yml +++ b/docker-compose.example.yml @@ -1,9 +1,6 @@ -version: "3.9" # Updated to the latest supported version as of 2024 services: autodns: - build: - context: . - dockerfile: Dockerfile + image:ghcr.io/bakerboy448/autodns:latest ports: - "4295:4295" volumes: @@ -12,5 +9,6 @@ services: CF_ZONE_ID: "your-zone-id" CF_API_TOKEN: "your-api-token" APPRISE_URLS: "your-apprise-urls-separated-by-commas" - FLASK_RUN_PORT: 4295 + AUTODNS_PORT: 4295 + AUTODNS_HOST: 0.0.0.0 # Any IPv4 restart: unless-stopped