-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
79 lines (59 loc) · 1.94 KB
/
Copy pathDockerfile
File metadata and controls
79 lines (59 loc) · 1.94 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
# Stage 1: Frontend Build
FROM node:20-alpine AS frontend-builder
# Accept version as build argument
ARG VERSION=dev
# Set environment variable for Next.js build
ENV NEXT_PUBLIC_APP_VERSION=${VERSION}
WORKDIR /app/frontend
# Copy package files
COPY frontend/package*.json ./
RUN npm install
# Copy frontend source and build
COPY frontend/ .
RUN npm run build
# Stage 2: Backend Production
FROM python:3.10-slim
# Accept version as build argument
ARG VERSION=dev
# Install system dependencies including build tools for ARM64 compatibility
RUN apt-get update && apt-get install -y \
ffmpeg \
curl \
gcc \
python3-dev \
build-essential \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# Create app user for security
RUN useradd -m -u 1000 appuser
# Set working directory
WORKDIR /app
# Copy requirements and install Python dependencies
COPY backend/requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
# Copy backend code
COPY backend/ ./
# Copy Next.js standalone build
COPY --from=frontend-builder /app/frontend/.next/standalone ./frontend/
COPY --from=frontend-builder /app/frontend/.next/static ./frontend/.next/static
COPY --from=frontend-builder /app/frontend/public ./frontend/public
# Install Node.js for running Next.js standalone
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
&& apt-get install -y nodejs
# Create app data directory structure
RUN mkdir -p /app/app_data/{database,recordings,logs,config} \
&& chown -R appuser:appuser /app
# Switch to non-root user
USER appuser
# Set environment variables
ENV VERSION=${VERSION}
ENV APP_DATA_DIR=/app/app_data
ENV PYTHONPATH=/app
ENV PYTHONUNBUFFERED=1
# Health check
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8000/health || exit 1
# Expose port
EXPOSE 8000
# Start the application
CMD ["python", "-m", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]