forked from techx/qstack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.prod
More file actions
95 lines (77 loc) · 2.69 KB
/
Copy pathDockerfile.prod
File metadata and controls
95 lines (77 loc) · 2.69 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
FROM node:18-alpine AS frontend-builder
WORKDIR /app/client
# Copy frontend package files
COPY client/package*.json ./
RUN npm ci && npm cache clean --force
# Copy frontend source
COPY client/ ./
# Build frontend (production mode)
RUN npm run build && rm -rf src node_modules
FROM python:3.9-slim-bullseye
# Install PostgreSQL and dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
postgresql \
postgresql-contrib \
gcc \
python3-dev \
libpq-dev \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean \
&& rm -rf /usr/share/postgresql/*/man \
&& rm -rf /usr/share/doc/postgresql* \
&& rm -rf /usr/share/locale/* \
&& find /usr/lib/postgresql -name '*.a' -delete
# Set working directory
WORKDIR /app
# Copy requirements and install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt gunicorn && \
rm -rf ~/.cache/pip && \
find /usr/local -type f -name '*.pyc' -delete && \
find /usr/local -type d -name '__pycache__' -exec rm -rf {} + 2>/dev/null || true
# Remove build dependencies after Python packages are installed
RUN apt-get purge -y --auto-remove gcc python3-dev && \
apt-get autoremove -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Copy application code
COPY server/ ./server/
COPY wsgi.py .
# Copy built frontend from builder stage
COPY --from=frontend-builder /app/client/dist ./client/dist
# Create PostgreSQL data directory
RUN mkdir -p /var/lib/postgresql/data && \
chown -R postgres:postgres /var/lib/postgresql
# Set defaults and internal config
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PORT=3001 \
DATABASE_URL=postgresql://qstack:qstack_prod_pass@localhost:5432/qstackdb \
SQLALCHEMY_DATABASE_URI=postgresql://qstack:qstack_prod_pass@localhost:5432/qstackdb \
# Auth defaults
AUTH_ENVIRONMENT=production \
MIN_ACCESS_ROLE=0 \
MIN_ADMIN_ROLE=1 \
AUTH_SERVER_URL=https://auth.hackpsu.org/api/sessionUser \
AUTH_LOGIN_URL=https://auth.hackpsu.org/login \
AUTH_LOGOUT_URL=https://auth.hackpsu.org/api/sessionLogout \
QSTACK_URL=https://qstack.hackpsu.org \
HACKPSU_API_URL=https://apiv3.hackpsu.org \
FRONTEND_URL=https://qstack.hackpsu.org \
BACKEND_URL=https://qstack.hackpsu.org \
# App defaults
ENVIRONMENT=production
# Required runtime env vars:
# - APP_SECRET_KEY
# - DISCORD_CLIENT_ID (optional)
# - DISCORD_CLIENT_SECRET (optional)
# - MENTOR_PASS (optional)
# Copy startup script
COPY start.prod.sh /app/start.sh
RUN chmod +x /app/start.sh
# Expose port
EXPOSE 3001
# Volume for PostgreSQL data persistence
VOLUME ["/var/lib/postgresql/data"]
# Start script
CMD ["/app/start.sh"]