slim dockerfile
Some checks failed
ci / build (push) Failing after 1h10m3s
ci / test (push) Failing after 13m29s

This commit is contained in:
CJ_Clippy 2025-09-24 23:13:21 -08:00
parent e7818f96c9
commit ab1ac88031
2 changed files with 68 additions and 29 deletions

View File

@ -1,19 +1,72 @@
FROM node:22
# === Build stage ===
FROM node:22 AS builder
# Set working directory
WORKDIR /app
# Install system-level dependencies
RUN apt-get update -y && \
# Install system-level dependencies required only for building
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get update -y && \
apt-get install -y --no-install-recommends \
build-essential \
git \
inotify-tools \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
# Copy and install dependencies
COPY package.json package-lock.json ./
RUN npm install --ignore-scripts=false --foreground-scripts --verbose
# Copy Prisma schema and generate client
COPY prisma ./prisma
RUN npx prisma generate
# Copy the rest of the code
COPY . .
# Build the app
RUN npm run build
# === Python pytorch ultralytics stage ===
FROM python:3 AS pystuff
WORKDIR /app
# Create a virtual environment for Python deps
# we use this venv to transfer built artifacts between Docker image layers
RUN python -m venv /app/venv
ENV PATH="/app/venv/bin:$PATH"
RUN . /app/venv/bin/activate
# COPY requirements.txt .
# Install python deps
RUN --mount=type=cache,target=/root/.cache/uv \
python3 -m pip install uv && \
uv pip install torch --index-url https://download.pytorch.org/whl/cpu && \
uv pip install ultralytics --no-deps && \
uv pip install vcsi
# we are avoiding installing using requirements.txt file because doing so with ultralytics would install 7GB worth of unecessary dependencies.
# === Runtime stage ===
FROM node:22-slim
# Set working directory
WORKDIR /app
ENV PATH="/app/venv/bin:$PATH"
# Install only runtime dependencies
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get update -y && \
apt-get install -y --no-install-recommends \
ca-certificates \
ffmpeg \
mktorrent \
python3 \
python3-pip \
python3-venv \
wget \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
# Install Shaka Packager
@ -39,26 +92,12 @@ ENV LD_LIBRARY_PATH="/app/whisper.cpp/build/src:/app/whisper.cpp/build/ggml/src:
# Install b2-cli
RUN wget https://github.com/Backblaze/B2_Command_Line_Tool/releases/download/v4.4.1/b2-linux -O /usr/local/bin/b2 && chmod +x /usr/local/bin/b2
# Copy and install dependencies
COPY package.json package-lock.json ./
RUN --mount=type=cache,target=/root/.npm npm install --ignore-scripts=false --foreground-scripts --verbose
# Copy Prisma schema and generate client
COPY prisma ./prisma
RUN npx prisma generate
# Copy the rest of the code
COPY . .
# Build the app
RUN npm run build
# Setup Python virtualenv
RUN python3 -m venv /app/venv
ENV PATH="/app/venv/bin:$PATH"
# Install python deps
RUN ./venv/bin/pip install --no-cache-dir -r requirements.txt
# Copy runtime artifacts from builder
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/prisma ./prisma
COPY --from=pystuff /app/venv /app/venv
# Expose the port
EXPOSE 5000

View File

@ -1,7 +1,7 @@
{
"name": "futureporn-our",
"private": true,
"version": "2.8.1",
"version": "2.8.2",
"type": "module",
"scripts": {
"dev": "concurrently npm:dev:serve npm:dev:build:server npm:dev:build:client npm:dev:worker npm:dev:compose npm:dev:sftp npm:dev:qbittorrent npm:dev:tailscale",
@ -116,4 +116,4 @@
"prisma": {
"seed": "tsx prisma/seed.ts"
}
}
}