Docker File Update

This commit is contained in:
2026-01-07 04:16:40 +00:00
parent 983b548d7b
commit abceb1be7b
6 changed files with 98 additions and 12 deletions

52
Dockerfile Normal file
View File

@@ -0,0 +1,52 @@
# Stage 1: Build Frontend (SvelteKit)
FROM node:20-slim AS frontend-builder
WORKDIR /app
COPY package.json package-lock.json ./
# Install dependencies
RUN npm ci
# Copy source
COPY . .
# Build static files (outputs to build/)
RUN npm run build
# Stage 2: Backend (Python Flask + GPU Support)
# Use official PyTorch image with CUDA 12.1 support
FROM pytorch/pytorch:2.2.0-cuda12.1-cudnn8-runtime
# Install system dependencies for audio (libsndfile) and ffmpeg
# reliable ffmpeg install on debian-based images
RUN apt-get update && apt-get install -y \
libsndfile1 \
ffmpeg \
git \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy python requirements
# We remove torch/torchaudio from requirements briefly during install to avoid re-installing CPU versions
# or we trust pip to see the installed version satisfies it.
COPY server/requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy backend code
COPY server/ .
# Copy built frontend from Stage 1 into the expected relative path
# app.py expects '../build', so we copy to /build and structure appropriately
# However, simpler is to copy build/ to /app/build and adjust app.py or folder structure.
# Let's mirror the structure: /app/server (WORKDIR) and /app/build
COPY --from=frontend-builder /app/build /app/build
# Set working directory to server where app.py resides
WORKDIR /app/server
# Environment variables
ENV PYTHONUNBUFFERED=1
ENV PORT=5000
# Expose port
EXPOSE ${PORT}
# Run the application
CMD ["python", "app.py"]