Rework Docker image for a minimal build/pull/push footprint
This commit is contained in:
@@ -51,26 +51,46 @@ RUN ln -s /usr/bin/python3 /usr/bin/python
|
|||||||
# install pytorch before cache bust to avoid redownloading pytorch
|
# install pytorch before cache bust to avoid redownloading pytorch
|
||||||
RUN pip install --no-cache-dir torch==2.9.1 torchvision==0.24.1 torchaudio==2.9.1 --index-url https://download.pytorch.org/whl/cu128 --break-system-packages
|
RUN pip install --no-cache-dir torch==2.9.1 torchvision==0.24.1 torchaudio==2.9.1 --index-url https://download.pytorch.org/whl/cu128 --break-system-packages
|
||||||
|
|
||||||
# Fix cache busting by moving CACHEBUST to right before git clone
|
|
||||||
ARG CACHEBUST=1234
|
|
||||||
ARG GIT_COMMIT=main
|
|
||||||
RUN echo "Cache bust: ${CACHEBUST}" && \
|
|
||||||
git clone https://github.com/ostris/ai-toolkit.git && \
|
|
||||||
cd ai-toolkit && \
|
|
||||||
git checkout ${GIT_COMMIT}
|
|
||||||
|
|
||||||
WORKDIR /app/ai-toolkit
|
WORKDIR /app/ai-toolkit
|
||||||
|
|
||||||
# copy requirements.txt to leverage docker cache
|
# ---------------------------------------------------------------------------- #
|
||||||
COPY requirements.txt /app/ai-toolkit/requirements.txt
|
# Dependency layers come BEFORE the source clone so they are only rebuilt (and
|
||||||
|
# only need to be re-pulled by servers) when the dependency manifests change,
|
||||||
|
# not on every code change.
|
||||||
|
# ---------------------------------------------------------------------------- #
|
||||||
|
|
||||||
# Install Python dependencies
|
# Install Python dependencies (only re-runs when requirements.txt changes)
|
||||||
|
COPY requirements.txt /app/ai-toolkit/requirements.txt
|
||||||
RUN pip install --no-cache-dir --break-system-packages -r requirements.txt && \
|
RUN pip install --no-cache-dir --break-system-packages -r requirements.txt && \
|
||||||
pip install setuptools==69.5.1 --no-cache-dir --break-system-packages
|
pip install setuptools==69.5.1 --no-cache-dir --break-system-packages
|
||||||
|
|
||||||
# Build UI
|
# Install Node dependencies (only re-runs when package.json / package-lock.json change)
|
||||||
WORKDIR /app/ai-toolkit/ui
|
COPY ui/package.json ui/package-lock.json /app/ai-toolkit/ui/
|
||||||
RUN npm install && \
|
RUN cd /app/ai-toolkit/ui && npm ci
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------- #
|
||||||
|
# Source code comes LAST. Only this layer (plus the UI build below) is rebuilt
|
||||||
|
# on a code change, so servers only re-pull the (small) source, not the deps.
|
||||||
|
# Clone to a temp dir and rsync the source in, preserving the dependency dirs
|
||||||
|
# already populated above (ui/node_modules) and the manifests already used.
|
||||||
|
# ---------------------------------------------------------------------------- #
|
||||||
|
ARG CACHEBUST=1234
|
||||||
|
ARG GIT_COMMIT=main
|
||||||
|
RUN echo "Cache bust: ${CACHEBUST}" && \
|
||||||
|
git clone https://github.com/ostris/ai-toolkit.git /tmp/ai-toolkit-src && \
|
||||||
|
cd /tmp/ai-toolkit-src && \
|
||||||
|
git checkout ${GIT_COMMIT} && \
|
||||||
|
rsync -a --delete \
|
||||||
|
--exclude '.git' \
|
||||||
|
--exclude 'ui/node_modules' \
|
||||||
|
--exclude 'requirements.txt' \
|
||||||
|
--exclude 'ui/package.json' \
|
||||||
|
--exclude 'ui/package-lock.json' \
|
||||||
|
/tmp/ai-toolkit-src/ /app/ai-toolkit/ && \
|
||||||
|
rm -rf /tmp/ai-toolkit-src
|
||||||
|
|
||||||
|
# Build UI (re-runs on code change, but reuses the cached node_modules above)
|
||||||
|
RUN cd /app/ai-toolkit/ui && \
|
||||||
npm run build && \
|
npm run build && \
|
||||||
npm run update_db
|
npm run update_db
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
VERSION = "0.10.10"
|
VERSION = "0.10.11"
|
||||||
|
|||||||
Reference in New Issue
Block a user