-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
80 lines (60 loc) · 2.12 KB
/
Copy pathDockerfile
File metadata and controls
80 lines (60 loc) · 2.12 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
# --- BACKEND BUILD STAGE ---
FROM --platform=linux/amd64 python:3.13-bookworm AS backend
ENV APP_HOME /app
WORKDIR $APP_HOME
ENV PYTHONUNBUFFERED 1
# Install required system packages
RUN apt-get update && apt-get install -y \
curl \
lsb-release \
gnupg \
supervisor \
nodejs \
npm \
nginx \
&& rm -rf /var/lib/apt/lists/*
# Create a virtual environment inside the container
RUN python -m venv /app/venv
# Activate the virtual environment and install dependencies
COPY socialbook/requirements.txt .
RUN /app/venv/bin/pip install --no-cache-dir -r requirements.txt
# Copy Django project files
COPY socialbook /app/socialbook
# --- FRONTEND BUILD STAGE ---
FROM node:18 AS frontend
WORKDIR /frontend
COPY frontend /frontend
# Accept the build argument for the API URL
ARG EXPO_PUBLIC_API_URL
ENV EXPO_PUBLIC_API_URL=$EXPO_PUBLIC_API_URL
# Run build and then copy app-ads.txt manually to the dist folder
RUN npm ci && npm run build && \
cp public/app-ads.txt dist/app-ads.txt && \
cp public/opengraph.png dist/opengraph.png && \
cp public/profile_icon.png dist/profile_icon.png
# --- FINAL STAGE ---
FROM --platform=linux/amd64 python:3.13-bookworm
WORKDIR /app
# Copy Django files from the backend stage
COPY --from=backend /app /app
# Install dependencies inside the virtual environment
RUN python -m venv /app/venv
COPY socialbook/requirements.txt .
RUN /app/venv/bin/pip install --no-cache-dir -r requirements.txt
# Copy frontend build files
COPY --from=frontend /frontend/dist /app/frontend/build
# Install and run NGINX as a Reverse Proxy
RUN apt-get update && apt-get install -y nginx supervisor
COPY nginx.conf /etc/nginx/nginx.conf
# Copy Supervisor configuration
COPY supervisord.conf /etc/supervisord.conf
# Set environment variables
ENV PATH="/app/venv/bin:$PATH"
ENV PYTHONPATH="/app/socialbook"
# Debug step - Check if Django is installed
RUN /app/venv/bin/python -m pip freeze
RUN /app/venv/bin/python -c "import django; print(django.get_version())"
# Expose necessary ports
EXPOSE 8080
# Start Supervisor, using the virtual environment's Python
CMD ["supervisord", "-c", "/etc/supervisord.conf"]