A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search
feat(docker): ship Google Chrome in the karakeep-chrome image
Mohamed Bassemea57af18d90d
diff --git a/.github/workflows/chrome.yml b/.github/workflows/chrome.ymlindex 8f67c761..aa19efab 100644--- a/.github/workflows/chrome.yml+++ b/.github/workflows/chrome.yml@@ -19,7 +19,8 @@ concurrency:env:IMAGE: ghcr.io/karakeep-app/karakeep-chrome- HEADLESS_SHELL_VERSION: 151.0.7922.47+ # Google Chrome version (amd64); arm64 images use Debian's Chromium.+ GOOGLE_CHROME_VERSION: 154.0.8037.57IMAGE_REVISION: r1jobs:@@ -63,6 +64,7 @@ jobs:build-args: |BUILD_REVISION=${{ github.sha }}BUILD_CREATED=${{ needs.metadata.outputs.created }}+ GOOGLE_CHROME_VERSION=${{ env.GOOGLE_CHROME_VERSION }}context: .file: docker/chrome/Dockerfileload: true@@ -111,7 +113,7 @@ jobs:- name: Refuse to overwrite the immutable tagenv:- VERSION_TAG: ${{ env.IMAGE }}:${{ env.HEADLESS_SHELL_VERSION }}-${{ env.IMAGE_REVISION }}+ VERSION_TAG: ${{ env.IMAGE }}:${{ env.GOOGLE_CHROME_VERSION }}-${{ env.IMAGE_REVISION }}run: |if docker buildx imagetools inspect "$VERSION_TAG" >/dev/null 2>&1; thenecho "Refusing to overwrite published image $VERSION_TAG"@@ -124,11 +126,12 @@ jobs:build-args: |BUILD_REVISION=${{ github.sha }}BUILD_CREATED=${{ needs.metadata.outputs.created }}+ GOOGLE_CHROME_VERSION=${{ env.GOOGLE_CHROME_VERSION }}context: .file: docker/chrome/Dockerfileplatforms: ${{ matrix.platform }}push: true- tags: ${{ env.IMAGE }}:${{ env.HEADLESS_SHELL_VERSION }}-${{ env.IMAGE_REVISION }}-${{ matrix.suffix }}+ tags: ${{ env.IMAGE }}:${{ env.GOOGLE_CHROME_VERSION }}-${{ env.IMAGE_REVISION }}-${{ matrix.suffix }}publish-manifest:name: Publish multi-architecture manifest@@ -158,7 +161,7 @@ jobs:env:LATEST_TAG: ${{ env.IMAGE }}:latestRELEASE_TAG: ${{ env.IMAGE }}:release- VERSION_TAG: ${{ env.IMAGE }}:${{ env.HEADLESS_SHELL_VERSION }}-${{ env.IMAGE_REVISION }}+ VERSION_TAG: ${{ env.IMAGE }}:${{ env.GOOGLE_CHROME_VERSION }}-${{ env.IMAGE_REVISION }}run: |docker buildx imagetools create \--tag "$VERSION_TAG" \@@ -171,7 +174,7 @@ jobs:env:LATEST_TAG: ${{ env.IMAGE }}:latestRELEASE_TAG: ${{ env.IMAGE }}:release- VERSION_TAG: ${{ env.IMAGE }}:${{ env.HEADLESS_SHELL_VERSION }}-${{ env.IMAGE_REVISION }}+ VERSION_TAG: ${{ env.IMAGE }}:${{ env.GOOGLE_CHROME_VERSION }}-${{ env.IMAGE_REVISION }}run: |docker buildx imagetools inspect "$VERSION_TAG"docker buildx imagetools inspect "$LATEST_TAG"diff --git a/docker/chrome/Dockerfile b/docker/chrome/Dockerfileindex 02eb00dc..b0aab36e 100644--- a/docker/chrome/Dockerfile+++ b/docker/chrome/Dockerfile@@ -1,22 +1,53 @@# syntax=docker/dockerfile:1.7-ARG HEADLESS_SHELL_VERSION=151.0.7922.47-ARG HEADLESS_SHELL_DIGEST=sha256:dabddca3d1b3d95f0004bd16c62e581b701e313b41cce1e36606db1bbac06db2+# Google Chrome only ships Linux builds for amd64, so arm64 images fall back to+# Debian's Chromium. Google Chrome is preferred where available: bot-protection+# vendors are much more suspicious of the Chromium build than of Chrome.+ARG DEBIAN_DIGEST=sha256:a99cfc517144bc59b1978475ec53b46ecabec7e43635402ee5b77cc54cd1b20a-FROM docker.io/chromedp/headless-shell:${HEADLESS_SHELL_VERSION}@${HEADLESS_SHELL_DIGEST}+FROM docker.io/library/debian:trixie-slim@${DEBIAN_DIGEST}-ARG HEADLESS_SHELL_VERSION-ARG HEADLESS_SHELL_DIGEST+ARG TARGETARCH+ARG DEBIAN_DIGEST+ARG GOOGLE_CHROME_VERSION=154.0.8037.57ARG BUILD_REVISION=unknownARG BUILD_CREATED=unknownLABEL org.opencontainers.image.title="Karakeep Chrome" \- org.opencontainers.image.description="Chrome Headless Shell tested and distributed for Karakeep" \+ org.opencontainers.image.description="Headless Chrome tested and distributed for Karakeep" \org.opencontainers.image.source="https://github.com/karakeep-app/karakeep" \org.opencontainers.image.revision="${BUILD_REVISION}" \org.opencontainers.image.created="${BUILD_CREATED}" \- org.opencontainers.image.version="${HEADLESS_SHELL_VERSION}" \- org.opencontainers.image.base.name="docker.io/chromedp/headless-shell:${HEADLESS_SHELL_VERSION}" \- org.opencontainers.image.base.digest="${HEADLESS_SHELL_DIGEST}"+ org.opencontainers.image.version="${GOOGLE_CHROME_VERSION}" \+ org.opencontainers.image.base.name="docker.io/library/debian:trixie-slim" \+ org.opencontainers.image.base.digest="${DEBIAN_DIGEST}"+RUN apt-get update \+ && apt-get install -y --no-install-recommends \+ ca-certificates \+ curl \+ socat \+ fonts-liberation \+ fonts-noto-core \+ fonts-noto-cjk \+ fonts-noto-color-emoji \+ && if [ "$TARGETARCH" = "amd64" ]; then \+ curl -fsSL -o /tmp/google-chrome.deb \+ "https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_${GOOGLE_CHROME_VERSION}-1_amd64.deb" \+ && apt-get install -y --no-install-recommends /tmp/google-chrome.deb \+ && rm /tmp/google-chrome.deb \+ && ln -s /usr/bin/google-chrome-stable /usr/local/bin/karakeep-chrome; \+ else \+ apt-get install -y --no-install-recommends chromium \+ && ln -s /usr/bin/chromium /usr/local/bin/karakeep-chrome; \+ fi \+ && apt-get purge -y curl \+ && apt-get autoremove -y \+ && rm -rf /var/lib/apt/lists/*++COPY --chmod=755 docker/chrome/entrypoint.sh /usr/local/bin/chrome-entrypoint.sh++ENV HOME=/tmpUSER 65534:65534+EXPOSE 9222+ENTRYPOINT ["/usr/local/bin/chrome-entrypoint.sh"]diff --git a/docker/chrome/README.md b/docker/chrome/README.mdindex b82be124..9a082976 100644--- a/docker/chrome/README.md+++ b/docker/chrome/README.md@@ -1,8 +1,14 @@# Karakeep Chrome-This directory defines Karakeep's minimal Chrome Headless Shell image.+This directory defines Karakeep's headless Chrome image: Google Chrome stable+(Debian's Chromium on arm64, which Google doesn't ship Linux builds for)+running in Chrome's new headless mode, with the DevTools endpoint exposed on+port 9222.-This image is built on top of (https://github.com/chromedp/docker-headless-shell).+It deliberately ships full Chrome rather than the much smaller Chrome Headless+Shell: in A/B tests against bot-protected sites, the headless shell was blocked+far more often (it leaks CDP automation even with a patched client), and so,+to a lesser extent, was the Chromium build.## Testing locally@@ -20,14 +26,14 @@ native target architectures before publishing.## Updating the image-1. Choose an exact `chromedp/headless-shell` version that supports both target- architectures.-2. Resolve its multi-architecture index digest with- `docker buildx imagetools inspect`.-3. Update the version and digest in `Dockerfile` and the version and image- revision in `.github/workflows/chrome.yml`.-4. Open a pull request and let both native architecture build jobs pass.-5. After merge, manually dispatch the `Chrome Image` workflow from `main`.+1. Pick a Google Chrome stable version that's still available in Google's+ package pool+ (`https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/`).+2. Update `GOOGLE_CHROME_VERSION` in both `Dockerfile` and+ `.github/workflows/chrome.yml`, and reset the image revision in the+ workflow. The arm64 image installs Debian trixie's current Chromium.+3. Open a pull request and let both native architecture build jobs pass.+4. After merge, manually dispatch the `Chrome Image` workflow from `main`.Publishing is gated by the `chrome-production` GitHub environment.Use `-r1` for a new browser version. Increment the revision for a packaging-onlydiff --git a/docker/chrome/entrypoint.sh b/docker/chrome/entrypoint.shnew file mode 100755index 00000000..1dbc93a8--- /dev/null+++ b/docker/chrome/entrypoint.sh@@ -0,0 +1,21 @@+#!/bin/sh+# Runs Chrome in (new) headless mode with its DevTools endpoint exposed on port+# 9222. Chrome only binds the DevTools endpoint to localhost, so socat forwards+# the public port to it. Extra Chrome flags are passed as the container command.+set -e++socat TCP4-LISTEN:9222,fork,reuseaddr TCP4:127.0.0.1:9223 &++# SwiftShader keeps WebGL available without a GPU (even with --disable-gpu);+# a browser without WebGL is an easy headless tell.+exec karakeep-chrome \+ --headless=new \+ --no-sandbox \+ --no-first-run \+ --no-default-browser-check \+ --user-data-dir=/tmp/chrome-profile \+ --use-angle=swiftshader \+ --enable-unsafe-swiftshader \+ --remote-debugging-address=127.0.0.1 \+ --remote-debugging-port=9223 \+ "$@"