-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
57 lines (45 loc) · 1.58 KB
/
Copy pathDockerfile
File metadata and controls
57 lines (45 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Dockerfile for Render Deployment
# Single unified container for Django API + Frontend
FROM python:3.11-slim
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
curl \
nodejs \
npm \
&& rm -rf /var/lib/apt/lists/*
# Copy and install Python dependencies
COPY src/dsms/requirements.txt ./requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY src/ ./src/
COPY manage.py ./
COPY static/ ./static/
COPY package.json package-lock.json ./
COPY webpack.config.js tsconfig.json tailwind.config.js postcss.config.js ./
# Install Node dependencies and build frontend
RUN npm ci --production=false && npm run build && rm -rf node_modules
# Set Python path and Django settings
ENV PYTHONPATH=/app/src
ENV DJANGO_SETTINGS_MODULE=dsms.conf.settings.production
# Collect static files
RUN python manage.py collectstatic --noinput || true
# Create non-root user (fast now that node_modules is removed)
RUN useradd -m -u 1000 dsms && chown -R dsms:dsms /app
USER dsms
# Expose port (Render sets PORT env var)
EXPOSE 8000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
CMD curl -f http://localhost:${PORT:-8000}/health/ || exit 1
# Start with gunicorn (with access logs enabled)
CMD gunicorn dsms.wsgi:application \
--bind 0.0.0.0:${PORT:-8000} \
--workers 2 \
--threads 4 \
--access-logfile - \
--error-logfile - \
--log-level info \
--capture-output \
--access-logformat '"%(m)s %(U)s%(q)s" %(s)s %(b)s %(L)ss'