Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
81 lines (61 loc) · 2.07 KB
/
Copy pathDockerfile
File metadata and controls
81 lines (61 loc) · 2.07 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
81
# Multi-stage Dockerfile for Music Metadata Engine
# Builds both frontend and backend in a single container
# ==================== STAGE 1: Frontend Build ====================
FROM node:20-slim AS frontend-builder
WORKDIR /build/frontend
# Copy package files
COPY frontend/package*.json ./
# Install dependencies
RUN npm install --legacy-peer-deps
# Copy frontend source
COPY frontend/ ./
# Build production bundle
RUN node node_modules/vite/bin/vite.js build
# ==================== STAGE 2: Python Backend ====================
FROM python:3.10-slim
# Install system dependencies for audio processing and PDF generation (WeasyPrint)
RUN apt-get update && apt-get install -y \
ffmpeg \
libsndfile1 \
libgomp1 \
curl \
libpango-1.0-0 \
libpangoft2-1.0-0 \
libharfbuzz0b \
libpangocairo-1.0-0 \
libgdk-pixbuf-2.0-0 \
libffi-dev \
shared-mime-info \
fonts-dejavu-core \
&& rm -rf /var/lib/apt/lists/*
# Create user
RUN useradd -m -u 1000 user
# Create necessary directories and set permissions
RUN mkdir -p /home/user/app/temp_uploads /home/user/app/logs /data && \
chown -R user:user /home/user/app /data && \
chmod -R 777 /data /home/user/app/temp_uploads /home/user/app/logs
# Switch to non-root user
USER user
# Set environment
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH \
PYTHONUNBUFFERED=1
WORKDIR $HOME/app
# Copy backend requirements and install
COPY --chown=user backend/requirements.txt ./
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# Copy backend code
COPY --chown=user backend/ ./
# Copy built frontend from stage 1
COPY --from=frontend-builder --chown=user /build/frontend/dist ./frontend/dist
# Port
EXPOSE 7860
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:7860/api/health/ || exit 1
# Copy entrypoint script
COPY --chown=user backend/entrypoint.sh /home/user/app/entrypoint.sh
RUN chmod +x /home/user/app/entrypoint.sh
# Start application
CMD ["/home/user/app/entrypoint.sh"]