Skip to content

Commit 058d1a9

Browse files
committed
add docker
1 parent 7c22e12 commit 058d1a9

File tree

3 files changed

+86
-2
lines changed

3 files changed

+86
-2
lines changed

.github/workflows/publish.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Publish Docker image
2+
3+
on:
4+
pull_request:
5+
branches: [ sd3 ]
6+
workflow_dispatch:
7+
8+
jobs:
9+
check_and_build:
10+
name: Check for new release and build multiarch Docker image
11+
runs-on: ubuntu-latest
12+
permissions:
13+
packages: write
14+
contents: write
15+
id-token: write
16+
steps:
17+
- name: Check out the repo
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Docker Buildx
21+
uses: docker/setup-buildx-action@v3
22+
23+
- name: Log in to Docker Hub
24+
uses: docker/login-action@v3
25+
with:
26+
username: ${{ secrets.DOCKER_USERNAME }}
27+
password: ${{ secrets.DOCKER_PASSWORD }}
28+
29+
- name: Extract metadata (tags, labels) for Docker
30+
id: meta
31+
uses: docker/metadata-action@v5
32+
with:
33+
images: umagistr/kohya-sd-scripts
34+
tags: |
35+
type=raw,value=latest
36+
37+
- name: Build and push multiarch Docker image
38+
uses: docker/build-push-action@v6
39+
with:
40+
context: .
41+
file: Dockerfile
42+
push: true
43+
platforms: linux/amd64,linux/arm64
44+
tags: ${{ steps.meta.outputs.tags }}
45+
labels: ${{ steps.meta.outputs.labels }}

Dockerfile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# syntax=docker/dockerfile:1
2+
FROM python:3.10-slim-bullseye
3+
4+
# RUN mount cache for multi-arch
5+
ARG TARGETARCH
6+
ARG TARGETVARIANT
7+
8+
# Set environment variables for pip
9+
ENV PIP_NO_CACHE_DIR=false \
10+
PIP_DISABLE_PIP_VERSION_CHECK=1 \
11+
PIP_DEFAULT_TIMEOUT=100 \
12+
PYTHONUNBUFFERED=1
13+
14+
# Install system dependencies
15+
RUN --mount=type=cache,id=apt-$TARGETARCH$TARGETVARIANT,sharing=locked,target=/var/cache/apt \
16+
--mount=type=cache,id=aptlists-$TARGETARCH$TARGETVARIANT,sharing=locked,target=/var/lib/apt/lists \
17+
apt-get update && apt-get install -y --no-install-recommends \
18+
build-essential \
19+
curl \
20+
git \
21+
libgl1-mesa-glx \
22+
libglib2.0-0 \
23+
&& rm -rf /var/lib/apt/lists/*
24+
25+
# Copy requirements file
26+
COPY requirements.txt .
27+
28+
# Install PyTorch and torchvision with caching
29+
RUN --mount=type=cache,id=pip-$TARGETARCH$TARGETVARIANT,sharing=locked,target=/root/.cache/pip \
30+
pip3 install torch==2.4.0 torchvision==0.19.0 --index-url https://download.pytorch.org/whl/cu124
31+
32+
# Install Python dependencies with caching
33+
RUN --mount=type=cache,id=pip-$TARGETARCH$TARGETVARIANT,sharing=locked,target=/root/.cache/pip \
34+
pip3 install -r requirements.txt
35+
36+

requirements.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ voluptuous==0.13.1
2020
huggingface-hub==0.24.5
2121
# for Image utils
2222
imagesize==1.4.1
23-
numpy<=2.0
2423
# for BLIP captioning
2524
# requests==2.28.2
2625
# timm==0.6.12
@@ -43,4 +42,8 @@ rich==13.7.0
4342
# for T5XXL tokenizer (SD3/FLUX)
4443
sentencepiece==0.2.0
4544
# for kohya_ss library
46-
-e .
45+
#-e .
46+
torch==2.4.0
47+
torchvision==0.19.0
48+
xformers==0.0.27.post2
49+
clearml

0 commit comments

Comments
 (0)