-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.fixed
More file actions
68 lines (45 loc) · 1.67 KB
/
Dockerfile.fixed
File metadata and controls
68 lines (45 loc) · 1.67 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
# Multi-stage Dockerfile for UTracker
# Stage 1: Build the frontend
FROM node:18-alpine AS frontend-builder
WORKDIR /app/frontend
# Copy frontend package files
COPY frontend/package*.json ./
# Install frontend dependencies
RUN npm cache clean --force && npm install --force
# Copy frontend source code
COPY frontend/ .
# Build the frontend
RUN npm run build
# Stage 2: Build the backend
FROM python:3.11-slim AS backend-builder
WORKDIR /app/backend
# Install system dependencies
RUN apt-get update && apt-get install -y gcc && rm -rf /var/lib/apt/lists/*
# Copy backend requirements
COPY backend/requirements.txt .
# Install Python dependencies
RUN pip install --no-cache-dir --upgrade pip && pip install --no-cache-dir -r requirements.txt
# Stage 3: Production backend image
FROM python:3.11-slim AS backend
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y gcc && rm -rf /var/lib/apt/lists/*
# Copy backend code
COPY backend/ .
# Copy both installed Python packages and executables from builder stage
COPY --from=backend-builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
COPY --from=backend-builder /usr/local/bin /usr/local/bin
# Expose port for the backend
EXPOSE 8001
# Start the backend server
CMD ["uvicorn", "server:app", "--host", "0.0.0.0", "--port", "8001"]
# Stage 4: Production frontend image
FROM nginx:alpine AS frontend
# Copy nginx configuration
COPY frontend/nginx.conf /etc/nginx/nginx.conf
# Copy built frontend files
COPY --from=frontend-builder /app/frontend/build /usr/share/nginx/html
# Expose port for the frontend
EXPOSE 80
# Default command for nginx
CMD ["nginx", "-g", "daemon off;"]