2d9297d9a3
* set redis backend url automatically for docker builds * initial docker build config * rename docker scripts * fix script paths * remove old Dockerfiles * set vite proxy base url depending on mode * docker build config for client/ * docker production build for client * refactor docker files * update nginx config to set maximum file size * reduce docker image size * fix demucs bug in docker * fix proxy timeout * add gpu capabality for api container * add compose files for dev and prod * add healthcheck for freqsplit-api * add model checkpoints to api image * set healthcheck retries to 24
69 lines
1.8 KiB
Docker
69 lines
1.8 KiB
Docker
# ---------------------
|
||
# Stage 1: Builder
|
||
# ---------------------
|
||
FROM python:3.12.7 AS builder
|
||
|
||
# Install build deps
|
||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||
build-essential libpq-dev git curl \
|
||
libffi-dev libssl-dev rustc cargo \
|
||
&& rm -rf /var/lib/apt/lists/*
|
||
|
||
WORKDIR /app
|
||
COPY src/ src/
|
||
|
||
# Copy metadata and install deps
|
||
COPY pyproject.toml requirements.txt ./
|
||
RUN pip install --upgrade pip && \
|
||
pip install --prefix=/install --no-cache-dir -e .
|
||
|
||
# --- Patch Demucs bug here ---
|
||
# Fixes the following error when using htdemucs model:
|
||
# RuntimeError: unsupported operation: more than one element of the written-to tensor refers to a single memory location. Please clone() the tensor before performing the operation.
|
||
RUN find /install -type f -path "*/site-packages/demucs/separate.py" \
|
||
-exec sed -i 's/wav -= ref.mean()/wav = (wav - ref.mean()).clone()/' {} \;
|
||
|
||
|
||
|
||
# Copy source for build-time extras (if needed)
|
||
COPY api/ api/
|
||
COPY docker/daphne api/
|
||
COPY docker/celery api/
|
||
COPY docker/wrapper api/
|
||
|
||
# ---------------------
|
||
# Stage 2: Runtime
|
||
# ---------------------
|
||
FROM python:3.12.7
|
||
# Install runtime system packages (only what’s needed)
|
||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||
libpq-dev curl libffi-dev libssl-dev wget\
|
||
&& rm -rf /var/lib/apt/lists/*
|
||
|
||
WORKDIR /app
|
||
|
||
# Copy only installed site-packages and app
|
||
COPY --from=builder /install /usr/local
|
||
COPY api/ api/
|
||
COPY src/ src/
|
||
COPY pytest.ini .
|
||
COPY tests/ tests/
|
||
COPY LICENSE .
|
||
COPY docker/daphne api/
|
||
COPY docker/celery api/
|
||
COPY docker/wrapper api/
|
||
|
||
# Test packages and download model checkpoints
|
||
RUN pytest
|
||
RUN rm pytest.ini
|
||
RUN rm -rf tests/
|
||
|
||
|
||
# Set working dir for backend
|
||
WORKDIR /app/api
|
||
|
||
ENV CELERY_BROKER_URL=redis://redis:6379/0
|
||
|
||
EXPOSE 8000
|
||
CMD ./wrapper
|