This commit is contained in:
Andrey Kondratev
2025-09-09 15:39:28 +05:00
parent 3b2d5ece24
commit d4debf9b63
33 changed files with 1274 additions and 9585 deletions

View File

@@ -1,59 +1,44 @@
# Build stage
FROM node:18-alpine AS builder
# Python Backend Dockerfile
FROM python:3.11-slim
WORKDIR /app
# Copy package files
COPY package*.json ./
COPY yarn.lock* ./
# Install all dependencies (including dev for build)
RUN yarn install --frozen-lockfile && yarn cache clean
# Copy source code
COPY . .
# Build the application
RUN yarn build
# Clean dev dependencies
RUN yarn install --production --frozen-lockfile
# Production stage
FROM node:18-alpine AS production
# Install ffmpeg from Alpine packages (architecture-aware)
RUN apk update && apk add --no-cache ffmpeg
# Install system dependencies
RUN apt-get update && apt-get install -y \
ffmpeg \
&& rm -rf /var/lib/apt/lists/*
# Set ffmpeg paths
ENV FFMPEG_PATH=/usr/bin/ffmpeg
ENV FFPROBE_PATH=/usr/bin/ffprobe
WORKDIR /app
# Copy requirements first for better Docker layer caching
COPY requirements.txt .
# Copy built application and dependencies
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/public ./public
COPY --from=builder /app/package*.json ./
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY backend/ ./backend/
COPY main.py .
COPY public/ ./public/
# Create necessary directories
RUN mkdir -p downloads database
# Create non-root user
RUN addgroup -g 1001 -S nodejs
RUN adduser -S quixotic -u 1001
RUN groupadd -r quixotic && useradd -r -g quixotic quixotic
# Change ownership of app directory
RUN chown -R quixotic:nodejs /app
RUN chown -R quixotic:quixotic /app
USER quixotic
# Expose port
EXPOSE 3000
EXPOSE 8000
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD node -e "require('http').get('http://localhost:3000/health', (res) => { process.exit(res.statusCode === 200 ? 0 : 1) })"
CMD python -c "import requests; requests.get('http://localhost:8000/health', timeout=3)"
# Start the application
CMD ["node", "dist/server.js"]
CMD ["python", "main.py"]