``` refactor: update settings and Docker config for production - Configure ALLOWED_HOSTS and CORS from environment variables for better security - Switch default database from PostgreSQL to SQLite3 (PostgreSQL config commented) - Simplify DEBUG environment variable handling - Update Dockerfile to use Python 3.11 and gunicorn for production - Add static file collection in Docker build process - Add user appointment statistics endpoint (user_apointment_stats) - Add .dockerignore to exclude unnecessary files from build These changes improve production readiness by making critical settings configurable via environment variables and using production-grade WSGI server (gunicorn) instead of Django development server.
35 lines
567 B
Plaintext
35 lines
567 B
Plaintext
FROM python:3.11-slim
|
|
|
|
# Set environment variables
|
|
ENV PYTHONDONTWRITEBYTECODE=1
|
|
ENV PYTHONUNBUFFERED=1
|
|
|
|
# Set work directory
|
|
WORKDIR /app
|
|
|
|
# Install dependencies
|
|
COPY requirements.txt /app/
|
|
RUN pip install --upgrade pip && \
|
|
pip install -r requirements.txt
|
|
|
|
# Copy project
|
|
COPY . /app/
|
|
|
|
# Collect static files
|
|
RUN python manage.py collectstatic --noinput
|
|
|
|
# Expose port
|
|
EXPOSE 8000
|
|
|
|
# Run gunicorn
|
|
CMD ["gunicorn", "myproject.wsgi:application", "--bind", "0.0.0.0:8000"]
|
|
```
|
|
|
|
**Optional: Create `.dockerignore`:**
|
|
```
|
|
*.pyc
|
|
__pycache__
|
|
db.sqlite3
|
|
.env
|
|
.git
|
|
venv/ |