ready to fly

This commit is contained in:
2025-02-28 23:10:45 +08:00
parent 0b5426a5d1
commit 18c756ae0f
5 changed files with 28 additions and 5 deletions

1
.gitignore vendored
View File

@@ -1,3 +1,4 @@
venv
**/__pycache__
db.sqlite3
.env

17
Dockerfile Normal file
View File

@@ -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" ]

View File

@@ -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

4
entrypoint.sh Normal file
View File

@@ -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

Binary file not shown.