From af25d9c5a2e3615e1813e5cf968c8e1f1d1cf887 Mon Sep 17 00:00:00 2001 From: ducklet Date: Sun, 11 Jul 2021 20:26:53 +0200 Subject: [PATCH] change the container to be more production ready This includes the code files in the docker image and creates a separate data dir, which means we don't need to manually mount files into the container anymore. --- .dockerignore | 2 ++ Dockerfile | 5 +++++ unwind/config.py | 8 +++++--- 3 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..4ff75da --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +*.local +/data \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 4d2a169..aebc293 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,5 +15,10 @@ RUN pip install --no-cache-dir --upgrade --requirement requirements.txt USER 10000:10001 +COPY . ./ + +ENV UNWIND_DATA="/data" +VOLUME ["/data"] + ENTRYPOINT ["/var/app/run"] CMD ["server"] diff --git a/unwind/config.py b/unwind/config.py index 624365a..26ad3ec 100644 --- a/unwind/config.py +++ b/unwind/config.py @@ -3,10 +3,12 @@ from pathlib import Path import toml -cachedir = ( - Path(cachedir) if (cachedir := os.getenv("UNWIND_CACHEDIR", "./.cache")) else None -) datadir = Path(os.getenv("UNWIND_DATA") or "./data") +cachedir = ( + Path(cachedir) + if (cachedir := os.getenv("UNWIND_CACHEDIR", datadir / ".cache")) + else None +) debug = os.getenv("DEBUG") == "1" loglevel = os.getenv("UNWIND_LOGLEVEL") or ("DEBUG" if debug else "INFO") storage_path = os.getenv("UNWIND_STORAGE", datadir / "db.sqlite")