-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
67 lines (48 loc) · 1.4 KB
/
Dockerfile
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
# Stage 1: Build frontend
FROM node:20-slim as frontend-builder
# Set working directory
WORKDIR /app/frontend
# Copy frontend package files
COPY frontend/package*.json ./
# Install dependencies
RUN npm install
# Copy frontend source code
COPY frontend/ ./
# Build frontend
RUN npm run build
# Stage 2: Python application with frontend assets
FROM python:3.12-slim
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV NODE_ENV production
# Install system dependencies
RUN apt-get update && apt-get install -y \
postgresql-client \
libpq-dev \
gcc \
&& rm -rf /var/lib/apt/lists/*
# Set the working directory
WORKDIR /app
# Copy the requirements file
COPY requirements.txt ./
# Install Python dependencies
RUN pip install --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt
# Copy the built frontend assets
COPY --from=frontend-builder /app/frontend/dist /app/frontend/dist
# Copy the rest of the application code
COPY . .
# Create directory for static files
RUN mkdir -p /app/staticfiles
# Collect static files
RUN python manage.py collectstatic --noinput
# Expose the port the app runs on
EXPOSE 8000
# Add startup script
COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh
# Set the entrypoint
ENTRYPOINT ["/docker-entrypoint.sh"]
# Default command
CMD ["gunicorn", "--bind", "0.0.0.0:8000", "offer_plus.wsgi:application"]