slim down docker image
This commit is contained in:
parent
e62bec708f
commit
f1c593ff17
@ -41,7 +41,7 @@ RUN wget https://github.com/Backblaze/B2_Command_Line_Tool/releases/download/v4.
|
|||||||
|
|
||||||
# Copy and install dependencies
|
# Copy and install dependencies
|
||||||
COPY package.json package-lock.json ./
|
COPY package.json package-lock.json ./
|
||||||
RUN npm install --ignore-scripts=false --foreground-scripts --verbose
|
RUN --mount=type=cache,target=/root/.npm npm install --ignore-scripts=false --foreground-scripts --verbose
|
||||||
|
|
||||||
# Copy Prisma schema and generate client
|
# Copy Prisma schema and generate client
|
||||||
COPY prisma ./prisma
|
COPY prisma ./prisma
|
||||||
|
@ -1,3 +1,2 @@
|
|||||||
ultralytics
|
ultralytics
|
||||||
vcsi
|
vcsi
|
||||||
torrentfile
|
|
105
services/our/slim.Dockerfile
Normal file
105
services/our/slim.Dockerfile
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
# === Build stage ===
|
||||||
|
FROM node:22 AS builder
|
||||||
|
|
||||||
|
# Set working directory
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# 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 -r requirements.txt
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# === 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 \
|
||||||
|
wget \
|
||||||
|
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Install Shaka Packager
|
||||||
|
RUN wget -q https://github.com/shaka-project/shaka-packager/releases/download/v3.4.2/packager-linux-x64 \
|
||||||
|
-O /usr/local/bin/packager \
|
||||||
|
&& chmod +x /usr/local/bin/packager \
|
||||||
|
&& packager --version
|
||||||
|
|
||||||
|
# Install IPFS Kubo
|
||||||
|
COPY --from=ipfs/kubo:v0.36.0 /usr/local/bin/ipfs /usr/local/bin/ipfs
|
||||||
|
RUN ipfs init
|
||||||
|
|
||||||
|
# Bundle the vibeui pytorch model
|
||||||
|
RUN mkdir -p /app/vibeui \
|
||||||
|
&& wget -q https://gitea.futureporn.net/futureporn/fp/raw/branch/main/apps/vibeui/public/vibeui.pt -O /app/vibeui/vibeui.pt \
|
||||||
|
&& wget -q https://gitea.futureporn.net/futureporn/fp/raw/branch/main/apps/vibeui/public/data.yaml -O /app/vibeui/data.yaml
|
||||||
|
|
||||||
|
# Install openwhisper
|
||||||
|
COPY --from=ghcr.io/ggml-org/whisper.cpp:main-e7bf0294ec9099b5fc21f5ba969805dfb2108cea /app /app/whisper.cpp
|
||||||
|
ENV PATH="$PATH:/app/whisper.cpp/build/bin"
|
||||||
|
ENV LD_LIBRARY_PATH="/app/whisper.cpp/build/src:/app/whisper.cpp/build/ggml/src:/usr/local/lib:/usr/lib"
|
||||||
|
|
||||||
|
# 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 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
|
||||||
|
|
||||||
|
COPY --from=builder /app /app
|
||||||
|
|
||||||
|
# Expose the port
|
||||||
|
EXPOSE 5000
|
||||||
|
|
||||||
|
# Start the app
|
||||||
|
CMD ["npm", "run", "start:server"]
|
Loading…
x
Reference in New Issue
Block a user