Skip to content

armgit / kokon

Public Imported from GitHub
0

Edit photos by describing the change, on your own GPU. A free, open-source alternative to Nano Banana and ChatGPT image editing: photos stay on your computer, no daily limit. One installer for Windows, Mac and Linux sets up the best open model (Qwen-Image 2.1). MCP server for AI agents.

Docker image for NVIDIA (CUDA) and an example compose file

Gabriele Lozuponeb0b8d6259d98
diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..364fc9b
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,14 @@
+# Only the sources kokon-service and the UI are built from (docker/Dockerfile).
+.git
+/target
+/src-tauri/target
+**/node_modules
+/dist
+/dist-release
+/mcp/build
+/private
+/marketing
+/site
+/docs/media
+
+*.log
diff --git a/docker/Dockerfile b/docker/Dockerfile
new file mode 100644
index 0000000..d9b99c6
--- /dev/null
+++ b/docker/Dockerfile
@@ -0,0 +1,47 @@
+# Kokon for NVIDIA GPUs (CUDA): kokon-service without a window, used from a browser.
+# The same Linux build as the .deb/.rpm (Ubuntu 22.04, glibc 2.35). The engine (stable-diffusion.cpp)
+# and the model are downloaded by Kokon's setup into /data, like in the desktop app, so the image
+# stays small; the NVIDIA Container Toolkit provides the driver. Guide: docs/docker.md.
+#
+# docker build -f docker/Dockerfile -t kokon .
+# docker compose -f docker/compose.yaml up -d
+
+FROM ubuntu:22.04 AS build
+ARG DEBIAN_FRONTEND=noninteractive
+RUN apt-get update \
+ && apt-get install -y --no-install-recommends build-essential ca-certificates curl pkg-config libssl-dev \
+ && curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
+ && apt-get install -y --no-install-recommends nodejs \
+ && rm -rf /var/lib/apt/lists/*
+RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal
+ENV PATH=/root/.cargo/bin:$PATH
+WORKDIR /src
+COPY package.json package-lock.json ./
+RUN npm ci --no-audit --no-fund
+COPY . .
+# The UI first: kokon-service embeds it (crates/qls-service/src/remote.rs).
+RUN npm run build && cargo build -p qls-service --release
+
+FROM ubuntu:22.04
+ARG DEBIAN_FRONTEND=noninteractive
+# What the .deb depends on (src-tauri/tauri.linux.conf.json), minus the window.
+RUN apt-get update \
+ && apt-get install -y --no-install-recommends ca-certificates libgomp1 libssl3 libvulkan1 \
+ && rm -rf /var/lib/apt/lists/*
+RUN useradd --create-home --uid 1000 kokon \
+ && mkdir -p /data /config /gallery \
+ && chown kokon:kokon /data /config /gallery
+COPY --from=build /src/target/release/kokon-service /usr/local/bin/kokon-service
+# Models, engine and gallery database in /data; settings in /config; saved images in /gallery.
+ENV QLS_DATA_DIR=/data \
+ QLS_CONFIG_DIR=/config \
+ QLS_OUTPUT_DIR=/gallery \
+ NVIDIA_VISIBLE_DEVICES=all \
+ NVIDIA_DRIVER_CAPABILITIES=compute,utility
+USER kokon
+VOLUME ["/data", "/config", "/gallery"]
+# The browser UI (password required). The token API on 39151 stays inside the container.
+EXPOSE 39152
+# --remote: open to other devices once a password is set
+# (docker exec -it kokon kokon-service --set-password; applies without a restart).
+CMD ["kokon-service", "--persistent", "--remote"]
diff --git a/docker/compose.yaml b/docker/compose.yaml
new file mode 100644
index 0000000..610de2d
--- /dev/null
+++ b/docker/compose.yaml
@@ -0,0 +1,39 @@
+# Kokon on an NVIDIA GPU, used from a browser: http://<this computer's address>:39152
+# Needs the NVIDIA Container Toolkit. First start, then set the password once:
+#
+# docker compose -f docker/compose.yaml up -d
+# docker exec -it kokon kokon-service --set-password
+#
+# Guide: docs/docker.md. For access from outside your home use Tailscale or another VPN
+# (docs/remote-access.md), never port forwarding on your router.
+services:
+ kokon:
+ image: kokon
+ build:
+ context: ..
+ dockerfile: docker/Dockerfile
+ container_name: kokon
+ restart: unless-stopped
+ ports:
+ # Every network interface of this computer. Docker's published ports skip host firewalls
+ # such as ufw; to reach Kokon only from this computer use "127.0.0.1:39152:39152".
+ - "39152:39152"
+ volumes:
+ - kokon-data:/data # engine, models (~13 GB), gallery database
+ - kokon-config:/config # settings
+ - kokon-gallery:/gallery # the images you save
+ # A folder of your own instead (Kokon runs as uid 1000, so it must own it):
+ # mkdir -p ~/kokon-gallery && sudo chown 1000:1000 ~/kokon-gallery
+ # - ~/kokon-gallery:/gallery
+ deploy:
+ resources:
+ reservations:
+ devices:
+ - driver: nvidia
+ count: all
+ capabilities: [gpu]
+
+volumes:
+ kokon-data:
+ kokon-config:
+ kokon-gallery: