diff --git a/Dockerfile b/Dockerfile index d441cbc..c22f4ef 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,6 +14,8 @@ COPY --from=build-stage /tmp/code/dist/ . RUN pip install --no-cache-dir --no-index --find-links . dnschef[api] +EXPOSE 80 53/udp 53/tcp + CMD ["uvicorn", "dnschef.api:app", "--host", "0.0.0.0", "--port", "80"] # If using a proxy diff --git a/dnschef/api.py b/dnschef/api.py index 3180d48..7d1a072 100644 --- a/dnschef/api.py +++ b/dnschef/api.py @@ -11,7 +11,7 @@ from typing import Optional, List from fastapi import FastAPI -from pydantic import BaseModel, BaseSettings #,IPvAnyAddress +from pydantic import BaseModel, BaseSettings, FilePath #,IPvAnyAddress from dnslib import RDMAP import logging @@ -31,6 +31,7 @@ class Settings(BaseSettings): ipv6: bool = False tcp: bool = False port: int = 53 + configfile: FilePath = "dnschef.ini" settings = Settings() app = FastAPI() @@ -38,7 +39,7 @@ class Settings(BaseSettings): @app.on_event("startup") async def startup_event(): print(header) - parse_config_file() + parse_config_file(settings.configfile) # Log to file fh = logging.handlers.WatchedFileHandler("dnschef.log") diff --git a/dnschef/utils.py b/dnschef/utils.py index c99b8c5..56987b4 100644 --- a/dnschef/utils.py +++ b/dnschef/utils.py @@ -14,6 +14,7 @@ def parse_config_file(config_file: str = "dnschef.ini"): + log.debug("Parsing config file", path=config_file) config = ConfigParser() config.read(config_file) for section in config.sections(): diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..a96fd03 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,20 @@ + +version: "3" +services: + dnschef: + image: dnschef:latest + container_name: dnschef + ports: + - "53:53/udp" + - "53:53/tcp" + expose: + - "80" + volumes: + - dnschef.ini:/etc/dnschef.ini + environment: + - INTERFACE=0.0.0.0 + - NAMESERVERS=8.8.8.8 + - PORT=53 + - TCP=false + - IPV6=false + - CONFIGFILE=/etc/dnschef.ini