Skip to content

Commit

Permalink
Added docker-compose.yml
Browse files Browse the repository at this point in the history
- Made the API accept an env variable pointing to config file
  • Loading branch information
byt3bl33d3r committed Dec 26, 2021
1 parent 88438dd commit 90ced9b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions dnschef/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -31,14 +31,15 @@ class Settings(BaseSettings):
ipv6: bool = False
tcp: bool = False
port: int = 53
configfile: FilePath = "dnschef.ini"

settings = Settings()
app = FastAPI()

@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")
Expand Down
1 change: 1 addition & 0 deletions dnschef/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
20 changes: 20 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 90ced9b

Please sign in to comment.