From c65f0bf66c4a9bc42ed58eb0c756ba6fd692a97c Mon Sep 17 00:00:00 2001 From: cxykevin Date: Sun, 25 Aug 2024 21:23:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90docker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dockerignore | 4 ++++ Dockerfile | 11 +++++++++++ config.sample.toml => config/config.sample.toml | 0 docker-compose.yml | 7 +++++++ server/cfg.py | 5 +++-- 5 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile rename config.sample.toml => config/config.sample.toml (100%) create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..c18adbd --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +*/__pycache__/** +venv +config.toml +config \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ae440c7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM python:3.12-slim + +COPY . /auth + +WORKDIR /auth + +RUN pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple + +EXPOSE 8000 + +CMD ["python", "main.py"] diff --git a/config.sample.toml b/config/config.sample.toml similarity index 100% rename from config.sample.toml rename to config/config.sample.toml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..506ed1d --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,7 @@ +services: + auth: + build: . + ports: + - "8000:8000" + volumes: + - ./config:/auth/config \ No newline at end of file diff --git a/server/cfg.py b/server/cfg.py index b7d3028..ad32670 100644 --- a/server/cfg.py +++ b/server/cfg.py @@ -1,10 +1,11 @@ import tomllib +import os -with open("config.toml", "rb") as f: +with open("config/config.toml", "rb") as f: config = tomllib.load(f) def reload(): global config - with open("config.toml", "rb") as f: + with open("config/config.toml", "rb") as f: config = tomllib.load(f)