slim dockerfile
This commit is contained in:
parent
e7818f96c9
commit
ab1ac88031
@ -1,19 +1,72 @@
|
|||||||
FROM node:22
|
# === Build stage ===
|
||||||
|
FROM node:22 AS builder
|
||||||
|
|
||||||
# Set working directory
|
# Set working directory
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Install system-level dependencies
|
# Install system-level dependencies required only for building
|
||||||
RUN apt-get update -y && \
|
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 \
|
apt-get install -y --no-install-recommends \
|
||||||
build-essential \
|
build-essential \
|
||||||
git \
|
git \
|
||||||
inotify-tools \
|
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 \
|
ffmpeg \
|
||||||
mktorrent \
|
wget \
|
||||||
python3 \
|
|
||||||
python3-pip \
|
|
||||||
python3-venv \
|
|
||||||
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Install Shaka Packager
|
# 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
|
# 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
|
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 runtime artifacts from builder
|
||||||
COPY package.json package-lock.json ./
|
COPY --from=builder /app/dist ./dist
|
||||||
RUN --mount=type=cache,target=/root/.npm npm install --ignore-scripts=false --foreground-scripts --verbose
|
COPY --from=builder /app/node_modules ./node_modules
|
||||||
|
COPY --from=builder /app/package.json ./package.json
|
||||||
# Copy Prisma schema and generate client
|
COPY --from=builder /app/prisma ./prisma
|
||||||
COPY prisma ./prisma
|
COPY --from=pystuff /app/venv /app/venv
|
||||||
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
|
|
||||||
|
|
||||||
# Expose the port
|
# Expose the port
|
||||||
EXPOSE 5000
|
EXPOSE 5000
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "futureporn-our",
|
"name": "futureporn-our",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "2.8.1",
|
"version": "2.8.2",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"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",
|
"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",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user