mirror of
https://github.com/open-webui/computer.git
synced 2026-11-22 21:50:43 -05:00
refac
This commit is contained in:
1 parent
e5ea8d72ed
commit
48db0611a8
4 files changed
+78
-20
No files matched your search
@@ -47,9 +47,23 @@ jobs:
|
||||
- platform: linux/amd64
|
||||
runner: ubuntu-latest
|
||||
arch: amd64
|
||||
target: default
|
||||
flavor: default
|
||||
- platform: linux/arm64
|
||||
runner: ubuntu-24.04-arm
|
||||
arch: arm64
|
||||
target: default
|
||||
flavor: default
|
||||
- platform: linux/amd64
|
||||
runner: ubuntu-latest
|
||||
arch: amd64
|
||||
target: browser
|
||||
flavor: browser
|
||||
- platform: linux/arm64
|
||||
runner: ubuntu-24.04-arm
|
||||
arch: arm64
|
||||
target: browser
|
||||
flavor: browser
|
||||
runs-on: ${{ matrix.runner }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
@@ -70,10 +84,11 @@ jobs:
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
target: ${{ matrix.target }}
|
||||
platforms: ${{ matrix.platform }}
|
||||
outputs: type=image,name=${{ env.IMAGE }},push-by-digest=true,name-canonical=true,push=true
|
||||
cache-from: type=gha,scope=dev-${{ matrix.arch }}
|
||||
cache-to: type=gha,mode=max,scope=dev-${{ matrix.arch }}
|
||||
cache-from: type=gha,scope=dev-${{ matrix.flavor }}-${{ matrix.arch }}
|
||||
cache-to: type=gha,mode=max,scope=dev-${{ matrix.flavor }}-${{ matrix.arch }}
|
||||
|
||||
- name: Export digest
|
||||
run: |
|
||||
@@ -84,7 +99,7 @@ jobs:
|
||||
- name: Upload digest
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: digests-dev-${{ matrix.arch }}
|
||||
name: digests-dev-${{ matrix.flavor }}-${{ matrix.arch }}
|
||||
path: /tmp/digests/*
|
||||
if-no-files-found: error
|
||||
retention-days: 1
|
||||
@@ -92,13 +107,16 @@ jobs:
|
||||
merge-dev:
|
||||
if: github.ref == 'refs/heads/main'
|
||||
needs: build-dev
|
||||
strategy:
|
||||
matrix:
|
||||
flavor: [default, browser]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Download digests
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: /tmp/digests
|
||||
pattern: digests-dev-*
|
||||
pattern: digests-dev-${{ matrix.flavor }}-*
|
||||
merge-multiple: true
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
@@ -115,9 +133,12 @@ jobs:
|
||||
working-directory: /tmp/digests
|
||||
run: |
|
||||
SHORT_SHA="${GITHUB_SHA::7}"
|
||||
docker buildx imagetools create \
|
||||
-t "${{ env.IMAGE }}:dev" \
|
||||
-t "${{ env.IMAGE }}:dev-${SHORT_SHA}" \
|
||||
if [ "${{ matrix.flavor }}" = default ]; then
|
||||
tags=("${{ env.IMAGE }}:dev" "${{ env.IMAGE }}:dev-${SHORT_SHA}")
|
||||
else
|
||||
tags=("${{ env.IMAGE }}:browser-dev" "${{ env.IMAGE }}:browser-dev-${SHORT_SHA}")
|
||||
fi
|
||||
docker buildx imagetools create $(printf -- '-t %s ' "${tags[@]}") \
|
||||
$(printf '${{ env.IMAGE }}@sha256:%s ' *)
|
||||
|
||||
# ── Release builds (release branch) ───────────────────────────────────────
|
||||
@@ -131,9 +152,23 @@ jobs:
|
||||
- platform: linux/amd64
|
||||
runner: ubuntu-latest
|
||||
arch: amd64
|
||||
target: default
|
||||
flavor: default
|
||||
- platform: linux/arm64
|
||||
runner: ubuntu-24.04-arm
|
||||
arch: arm64
|
||||
target: default
|
||||
flavor: default
|
||||
- platform: linux/amd64
|
||||
runner: ubuntu-latest
|
||||
arch: amd64
|
||||
target: browser
|
||||
flavor: browser
|
||||
- platform: linux/arm64
|
||||
runner: ubuntu-24.04-arm
|
||||
arch: arm64
|
||||
target: browser
|
||||
flavor: browser
|
||||
runs-on: ${{ matrix.runner }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
@@ -154,10 +189,11 @@ jobs:
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
target: ${{ matrix.target }}
|
||||
platforms: ${{ matrix.platform }}
|
||||
outputs: type=image,name=${{ env.IMAGE }},push-by-digest=true,name-canonical=true,push=true
|
||||
cache-from: type=gha,scope=release-${{ matrix.arch }}
|
||||
cache-to: type=gha,mode=max,scope=release-${{ matrix.arch }}
|
||||
cache-from: type=gha,scope=release-${{ matrix.flavor }}-${{ matrix.arch }}
|
||||
cache-to: type=gha,mode=max,scope=release-${{ matrix.flavor }}-${{ matrix.arch }}
|
||||
|
||||
- name: Export digest
|
||||
run: |
|
||||
@@ -168,7 +204,7 @@ jobs:
|
||||
- name: Upload digest
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: digests-release-${{ matrix.arch }}
|
||||
name: digests-release-${{ matrix.flavor }}-${{ matrix.arch }}
|
||||
path: /tmp/digests/*
|
||||
if-no-files-found: error
|
||||
retention-days: 1
|
||||
@@ -176,13 +212,16 @@ jobs:
|
||||
merge-release:
|
||||
needs: [read-version, build-release]
|
||||
if: github.ref == 'refs/heads/release'
|
||||
strategy:
|
||||
matrix:
|
||||
flavor: [default, browser]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Download digests
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: /tmp/digests
|
||||
pattern: digests-release-*
|
||||
pattern: digests-release-${{ matrix.flavor }}-*
|
||||
merge-multiple: true
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
@@ -200,8 +239,10 @@ jobs:
|
||||
run: |
|
||||
VERSION="${{ needs.read-version.outputs.version }}"
|
||||
MAJOR_MINOR="${VERSION%.*}"
|
||||
docker buildx imagetools create \
|
||||
-t "${{ env.IMAGE }}:latest" \
|
||||
-t "${{ env.IMAGE }}:${VERSION}" \
|
||||
-t "${{ env.IMAGE }}:${MAJOR_MINOR}" \
|
||||
if [ "${{ matrix.flavor }}" = default ]; then
|
||||
tags=("${{ env.IMAGE }}:latest" "${{ env.IMAGE }}:${VERSION}" "${{ env.IMAGE }}:${MAJOR_MINOR}")
|
||||
else
|
||||
tags=("${{ env.IMAGE }}:browser" "${{ env.IMAGE }}:${VERSION}-browser" "${{ env.IMAGE }}:${MAJOR_MINOR}-browser")
|
||||
fi
|
||||
docker buildx imagetools create $(printf -- '-t %s ' "${tags[@]}") \
|
||||
$(printf '${{ env.IMAGE }}@sha256:%s ' *)
|
||||
+18
-4
@@ -22,15 +22,15 @@ COPY --from=frontend-builder /build/frontend/build cptr/frontend/build
|
||||
RUN uv build --wheel --out-dir /dist
|
||||
|
||||
|
||||
# ── Stage 3: Minimal runtime image ─────────────────────────
|
||||
# ── Stage 3: Shared runtime ────────────────────────────────
|
||||
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim AS runtime
|
||||
|
||||
LABEL org.opencontainers.image.source="https://github.com/open-webui/computer"
|
||||
LABEL org.opencontainers.image.description="cptr: your computer, from anywhere"
|
||||
LABEL org.opencontainers.image.description="Open WebUI Computer"
|
||||
|
||||
# Runtime deps: git for git operations, tini for PID 1
|
||||
# Runtime deps shared by default and browser images.
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends git tini && \
|
||||
apt-get install -y --no-install-recommends gh git tini && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Create non-root user and writable data directory
|
||||
@@ -55,3 +55,17 @@ VOLUME ["/data"]
|
||||
|
||||
ENTRYPOINT ["tini", "--"]
|
||||
CMD ["cptr", "run", "--host", "0.0.0.0", "--port", "8000", "--headless"]
|
||||
|
||||
|
||||
# ── Browser image: Chromium for agent browser automation ───
|
||||
FROM runtime AS browser
|
||||
|
||||
USER root
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends chromium && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
USER cptr
|
||||
|
||||
|
||||
# ── Default image ──────────────────────────────────────────
|
||||
FROM runtime AS default
|
||||
@@ -170,6 +170,7 @@ docker run --rm -it \
|
||||
Then open the URL printed in the logs, usually `http://localhost:8000/?token=...`.
|
||||
|
||||
Open WebUI Computer stores its state in `/data`. Mount your project into the container, like `-v "$PWD:/workspace"`, so Open WebUI Computer can access it.
|
||||
The default image includes Git and GitHub CLI (`gh`). Use `ghcr.io/open-webui/computer:browser` when agent browser automation needs Chromium.
|
||||
|
||||
If you bind-mount a host directory to `/data`, make sure that directory is writable by the container user. SQLite needs to create and update `/data/app.db`, and host directory permissions take precedence over the image's built-in `/data` ownership.
|
||||
|
||||
|
||||
@@ -134,8 +134,10 @@ async def ensure_browser(port: int = 9222) -> str:
|
||||
"--disable-translate",
|
||||
"--disable-extensions",
|
||||
f"--user-data-dir={_user_data_dir}",
|
||||
"about:blank",
|
||||
]
|
||||
if Path("/.dockerenv").exists():
|
||||
args.append("--no-sandbox")
|
||||
args.append("about:blank")
|
||||
|
||||
logger.info("Launching Chrome: %s", " ".join(args[:3]))
|
||||
|
||||
|
||||
Reference in new issue
Block a user