From 18c756ae0fbd0376aca7a67a5a98249be7562f0b Mon Sep 17 00:00:00 2001 From: yuetsh <517252939@qq.com> Date: Fri, 28 Feb 2025 23:10:45 +0800 Subject: [PATCH] ready to fly --- .gitignore | 3 ++- Dockerfile | 17 +++++++++++++++++ api/settings.py | 9 +++++---- entrypoint.sh | 4 ++++ requirements.txt | Bin 332 -> 926 bytes 5 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 Dockerfile create mode 100644 entrypoint.sh diff --git a/.gitignore b/.gitignore index 08ee92f..64ab79e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ venv **/__pycache__ -db.sqlite3 \ No newline at end of file +db.sqlite3 +.env \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..79c083a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM python:3.12-alpine + +WORKDIR /app + +EXPOSE 8000 + +COPY requirements.txt /app + +RUN pip config set global.index-url https://mirrors.ustc.edu.cn/pypi/web/simple + +RUN pip install --no-cache-dir -r requirements.txt + +COPY . /app + +RUN chmod +x /app/entrypoint.sh + +ENTRYPOINT [ "/app/entrypoint.sh" ] \ No newline at end of file diff --git a/api/settings.py b/api/settings.py index d68808b..41ae2b4 100644 --- a/api/settings.py +++ b/api/settings.py @@ -10,6 +10,7 @@ For the full list of settings and their values, see https://docs.djangoproject.com/en/5.1/ref/settings/ """ +import os from pathlib import Path # Build paths inside the project like this: BASE_DIR / 'subdir'. @@ -20,12 +21,12 @@ BASE_DIR = Path(__file__).resolve().parent.parent # See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = "django-insecure-hh=iag^*2+(qj04_)9sup5v9nf$n5=ezs02zgcd3yh4n2u_1qd" +SECRET_KEY = os.getenv("SECRET_KEY") # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True +DEBUG = False -ALLOWED_HOSTS = [] +ALLOWED_HOSTS = ["web.xuyue.cc", "localhost", "127.0.0.1"] # Application definition @@ -129,5 +130,5 @@ DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" AUTH_USER_MODEL = "account.User" -CORS_ALLOWED_ORIGINS = ["http://localhost:3000", "https://web.xuyue.cc"] +CORS_ALLOWED_ORIGINS = ["http://localhost:8098", "https://web.xuyue.cc"] CORS_ALLOW_CREDENTIALS = True diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..a7d9019 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +python manage.py migrate --noinput +exec gunicorn --bind 0.0.0.0:8000 api.asgi:application -k uvicorn.workers.UvicornWorker \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index f4ded958eb666009dd799867a3a27e82106ee5b4..0ad3953179a990920ddc0bb9805aa15a3c422a54 100644 GIT binary patch literal 926 zcmZ8gK~lm%5bU#6J_U;`h+e#T^5nrPk5o*SfZ~D)SmNW=?in@#Yikp-J<~nYv;6*) zNL(B2P;y7q81a3;mcKjPagA|>8}2bKalxn#4OVE0FASd$yX7tnuXws3uFS$tm7B3O zkqU2ydX93%Td{^UcT0tL?yNjz_NWqLo&8NeDFM)BP;ei$0v2wd(F4{Yx{WRIA?=BdE~V4%;=gqW=YQq%XKf@6-`3i ziR`LXImMCHdx&Hmbd?*pGV7Lknr~@$M6QY@nCHQ!s7@>PTbgt7&m){i`if9@nzee! zxa!Dr`5!Z9oO+FYbTI#1^O1}Xc*awYI+x$d4j*)Ms7QKJ(oL9H&HjH-{|zS)q5Bv4 n)v-QJY`6i1dEu%%d>^OeUIwxTV|CpZSw$1s-+cyiu);-|Ih$h$tUJbs6mlJ6Z z05{2yu)P{gNO?FMT9?>u?rx6}c{;J#Osr@r$6Ag+?9n0jiT+x@@$wc+NUg1z^OksL zl8T>nI@3p^)NK~4iI}qcgEiL{sd&?N)yOyfH&(vNb;U($aj&oMZx2R^{B?Da7R^mg Uf^+h;ubhCR>;v^*C_YB~0szitMF0Q*