forked from rustdesk/rustdesk
-
Notifications
You must be signed in to change notification settings - Fork 0
feat(web): OSS-compatible web client with Docker build and CI #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
fe2febc
fix(web): support full wss:// URLs in config.json
rophy 684ba5c
build: add Dockerfile for web client
rophy 6ce8e2c
build: add Rust toolchain and Chrome to web dev container
rophy f7512c4
test: add unit tests for web client URL handling
rophy 0fc704c
test: increase web client JS unit test coverage to 84%
rophy 448ec0c
chore: gitignore core dumps, playwright artifacts, and coverage output
rophy 1b75590
build: add CI pipeline for web client Docker image
rophy 6623e84
fix: address review feedback from CodeRabbit
rophy 2000f78
fix: address remaining CodeRabbit review feedback
rophy c844dda
fix: add flutter/assets to web CI path filter
rophy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| name: Web client CI | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths: | ||
| - 'flutter/web/**' | ||
| - 'flutter/lib/**' | ||
| - 'flutter/assets/**' | ||
| - 'flutter/pubspec.*' | ||
| - 'Dockerfile.webclient' | ||
| - '.github/workflows/web-docker.yml' | ||
| - '.github/patches/flutter_3.24.4_dropdown_menu_enableFilter.diff' | ||
| push: | ||
| tags: ['*'] | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| workflow_dispatch: | ||
|
|
||
| env: | ||
| REGISTRY: ghcr.io | ||
| IMAGE_NAME: ${{ github.repository_owner }}/rustdesk-webclient | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-22.04 | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| submodules: recursive | ||
| persist-credentials: false | ||
|
|
||
| - name: Setup Node | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 22 | ||
|
|
||
| - name: Install protoc | ||
| run: sudo apt-get update && sudo apt-get install -y protobuf-compiler | ||
|
|
||
| - name: Install and test | ||
| working-directory: flutter/web/js | ||
| run: | | ||
| yarn install | ||
| python3 ./gen_js_from_hbb.py > src/gen_js_from_hbb.ts | ||
| python3 ./ts_proto.py | ||
| yarn test | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| build: | ||
| needs: test | ||
| runs-on: ubuntu-22.04 | ||
| permissions: | ||
| contents: read | ||
| packages: write | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| submodules: recursive | ||
| persist-credentials: false | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
|
|
||
| - name: Log in to GHCR | ||
| if: startsWith(github.ref, 'refs/tags/') | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| registry: ${{ env.REGISTRY }} | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Extract metadata | ||
| id: meta | ||
| uses: docker/metadata-action@v5 | ||
| with: | ||
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
| tags: | | ||
| type=semver,pattern={{version}} | ||
| type=semver,pattern={{major}}.{{minor}} | ||
|
|
||
| - name: Build and push | ||
| uses: docker/build-push-action@v6 | ||
| with: | ||
| context: . | ||
| file: Dockerfile.webclient | ||
| push: ${{ startsWith(github.ref, 'refs/tags/') }} | ||
| tags: ${{ steps.meta.outputs.tags }} | ||
| labels: ${{ steps.meta.outputs.labels }} | ||
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| FROM --platform=linux/amd64 ubuntu:22.04 AS build | ||
|
Check warning on line 1 in Dockerfile.webclient
|
||
|
|
||
| ARG FLUTTER_VERSION=3.24.5 | ||
| ARG NODE_MAJOR=22 | ||
|
|
||
| RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
| wget curl git unzip xz-utils ca-certificates python3 gnupg \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key \ | ||
| | gpg --dearmor -o /usr/share/keyrings/nodesource.gpg \ | ||
| && echo "deb [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_${NODE_MAJOR}.x nodistro main" \ | ||
| > /etc/apt/sources.list.d/nodesource.list \ | ||
| && apt-get update && apt-get install -y nodejs \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| RUN wget -q https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_${FLUTTER_VERSION}-stable.tar.xz \ | ||
| && tar xf flutter_linux_${FLUTTER_VERSION}-stable.tar.xz -C /opt \ | ||
| && rm flutter_linux_${FLUTTER_VERSION}-stable.tar.xz | ||
|
|
||
| ENV PATH="/opt/flutter/bin:${PATH}" | ||
|
|
||
| RUN npm install -g yarn typescript protoc | ||
|
|
||
| COPY .github/patches/flutter_3.24.4_dropdown_menu_enableFilter.diff /tmp/flutter.diff | ||
| RUN cd /opt/flutter && git apply /tmp/flutter.diff && rm /tmp/flutter.diff | ||
|
|
||
| RUN flutter config --no-analytics && flutter precache --web | ||
|
|
||
| RUN git config --global --add safe.directory /opt/flutter \ | ||
| && git config --global --add safe.directory /build | ||
|
|
||
| WORKDIR /build | ||
| COPY . . | ||
|
|
||
| WORKDIR /build/flutter/web/js | ||
| RUN yarn install && yarn build | ||
|
|
||
| WORKDIR /build/flutter | ||
| ARG WEB_DEPS_SHA256=b66011c4fc066b90c46ba0c78884fe5d1a7e5a7fad3dce401300ad893de63818 | ||
| RUN wget -q -O /tmp/web_deps.tar.gz \ | ||
| https://github.com/rustdesk/doc.rustdesk.com/releases/download/console/web_deps.tar.gz \ | ||
| && echo "${WEB_DEPS_SHA256} /tmp/web_deps.tar.gz" | sha256sum -c - \ | ||
| && flutter pub get && flutter build web --release \ | ||
| && tar xzf /tmp/web_deps.tar.gz -C build/web | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| # --- Production stage --- | ||
| FROM nginx:alpine | ||
|
|
||
| COPY --from=build /build/flutter/build/web /usr/share/nginx/html | ||
|
|
||
| COPY <<'EOF' /docker-entrypoint.d/90-rustdesk-config.sh | ||
| #!/bin/sh | ||
| set -e | ||
| CONFIG=/usr/share/nginx/html/config.json | ||
| if [ -n "$RUSTDESK_HOST" ]; then | ||
| cat > "$CONFIG" <<CONF | ||
| { | ||
| "host": "${RUSTDESK_HOST}", | ||
| "relay": "${RUSTDESK_RELAY:-$RUSTDESK_HOST}", | ||
| "key": "${RUSTDESK_KEY:-}", | ||
| "api": "${RUSTDESK_API:-}" | ||
| } | ||
| CONF | ||
| echo "config.json written: host=$RUSTDESK_HOST relay=${RUSTDESK_RELAY:-$RUSTDESK_HOST}" | ||
| fi | ||
| EOF | ||
| RUN chmod +x /docker-entrypoint.d/90-rustdesk-config.sh | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| legacy-peer-deps=true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| /** | ||
| * @vitest-environment jsdom | ||
| */ | ||
| import { describe, it, expect, vi, beforeEach } from "vitest"; | ||
|
|
||
| vi.mock("wasm-feature-detect", () => ({ | ||
| simd: vi.fn(), | ||
| })); | ||
|
|
||
| import { simd } from "wasm-feature-detect"; | ||
| import { loadVp9 } from "./codec"; | ||
|
|
||
| describe("loadVp9", () => { | ||
| let mockDecoder: any; | ||
| let mockLoadClass: any; | ||
|
|
||
| beforeEach(() => { | ||
| mockDecoder = { | ||
| init: vi.fn((cb: Function) => cb(mockDecoder)), | ||
| }; | ||
| mockLoadClass = vi.fn((className: string, callback: Function, opts: any) => { | ||
| callback(vi.fn().mockResolvedValue(mockDecoder)); | ||
| }); | ||
| (window as any).OGVLoader = { loadClass: mockLoadClass }; | ||
| (window as any).videoCodecClass = undefined; | ||
| }); | ||
|
|
||
| it("loads SIMD codec when SIMD is supported", async () => { | ||
| vi.mocked(simd).mockResolvedValue(true); | ||
| const callback = vi.fn(); | ||
| await loadVp9(callback); | ||
| expect(mockLoadClass).toHaveBeenCalledWith( | ||
| "OGVDecoderVideoVP9SIMDW", | ||
| expect.any(Function), | ||
| { worker: true, threading: true } | ||
| ); | ||
| expect(callback).toHaveBeenCalledWith(mockDecoder); | ||
| }); | ||
|
|
||
| it("loads non-SIMD codec when SIMD is not supported", async () => { | ||
| vi.mocked(simd).mockResolvedValue(false); | ||
| const callback = vi.fn(); | ||
| await loadVp9(callback); | ||
| expect(mockLoadClass).toHaveBeenCalledWith( | ||
| "OGVDecoderVideoVP9W", | ||
| expect.any(Function), | ||
| { worker: true, threading: true } | ||
| ); | ||
| expect(callback).toHaveBeenCalledWith(mockDecoder); | ||
| }); | ||
|
|
||
| it("sets window.videoCodecClass", async () => { | ||
| vi.mocked(simd).mockResolvedValue(false); | ||
| await loadVp9(vi.fn()); | ||
| expect((window as any).videoCodecClass).toBeDefined(); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.