1
+ # ---- Base Node ----
2
+ FROM node:14 AS base
3
+ WORKDIR /app
4
+ COPY package*.json ./
5
+
6
+ # ---- Dependencies ----
7
+ FROM base AS dependencies
8
+ RUN npm set progress=false && npm config set depth 0
9
+ RUN npm install --only=production
10
+ COPY . .
11
+ RUN npm run build
12
+
13
+ # ---- Copy Frontend Artifacts ----
14
+ # Separate stage for extracting frontend build artifacts
15
+ FROM dependencies AS frontend-artifacts
16
+ RUN mkdir -p /app/public
17
+ RUN cp -R build/ /app/public/
18
+
19
+ # ---- Python Base ----
20
+ FROM python:3.8 AS python-base
21
+ WORKDIR /app
22
+ COPY --from=frontend-artifacts /app/public /app/public
23
+ COPY backend/requirements.txt /app/
24
+ RUN pip install --no-cache-dir -r requirements.txt
25
+
26
+ # ---- Copy Backend Code ----
27
+ FROM python-base AS backend-code
28
+ COPY backend /app
29
+
30
+ # ---- Release with Gunicorn ----
31
+ FROM backend-code AS release
32
+ # Set environment variables
33
+ ENV PYTHONUNBUFFERED=1 \
34
+ PYTHONDONTWRITEBYTECODE=1 \
35
+ PATH="/app:${PATH}"
36
+
37
+ # Expose port for the backend
38
+ EXPOSE 8080
39
+
40
+ # Start Gunicorn (adjust the number of workers and threads as necessary)
41
+ CMD ["gunicorn" , "--bind" , "0.0.0.0:8080" , "--workers" , "3" , "--threads" , "3" , "myproject.wsgi:application" ]
42
+ CMD ["python" , "manage.py" , "runserver" ]
43
+ CMD ["python" , "manage.py" , "collectstatic" , "--noinput" ]
44
+ CMD ["python" , "manage.py" , "migrate" ]
45
+ CMD ["python" , "manage.py" , "createsuperuser" ]
0 commit comments