From 9bff75464d519a46b7fd61dac45a3059c9a71599 Mon Sep 17 00:00:00 2001 From: Levi Date: Fri, 9 Aug 2024 18:28:44 +0800 Subject: [PATCH] ci: docker flutter build on host (#637) --- .dockerignore | 16 ++++++++++++++++ .github/release-drafter.yml | 3 +++ .github/workflows/build.yml | 12 +++++++++++- Dockerfile | 10 +--------- entrypoint.sh | 2 +- 5 files changed, 32 insertions(+), 11 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..a392ec8b3 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,16 @@ +.git + +*.data +*.log + +node_modules +**/node_modules + +Dockerfile +.dockerignore + +.github +_docs +_examples +bin +ui \ No newline at end of file diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index 72cca8342..c802265dd 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -11,6 +11,9 @@ categories: - 'fix' - 'bugfix' - 'bug' + - title: '🔧 Performance Improvements' + labels: + - 'perf' - title: '🧪 Tests' label: 'test' - title: '🧰 Maintenance' diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f93ca7a5c..080985871 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -483,6 +483,9 @@ jobs: run: | sudo rm -rf /usr/share/dotnet sudo rm -rf "$AGENT_TOOLSDIRECTORY" + - uses: subosito/flutter-action@v2 + with: + flutter-version: ${{ env.FLUTTER_VERSION }} - uses: actions/checkout@v3 - name: Set up QEMU uses: docker/setup-qemu-action@v2 @@ -493,11 +496,19 @@ jobs: with: username: liwei2633 password: ${{ secrets.DOCKER_PASSWORD }} + - name: Build flutter web + run: | + cd ui/flutter + flutter build web --web-renderer html + cd ../../ + rm -rf cmd/web/dist + cp -r ui/flutter/build/web cmd/web/dist - name: Build and push uses: docker/build-push-action@v2 env: VERSION: ${{ needs.get-release.outputs.version }} with: + context: . push: ${{ github.event.inputs.test == 'true' && 'false' || 'true' }} build-args: | VERSION=${{ env.VERSION }} @@ -507,7 +518,6 @@ jobs: linux/amd64 linux/arm64 linux/arm/v7 - linux/arm64/v8 tags: | liwei2633/gopeed:latest liwei2633/gopeed:v${{ env.VERSION }} diff --git a/Dockerfile b/Dockerfile index e5d5ea845..a319072dc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,8 @@ -FROM instrumentisto/flutter:3.16.8 AS flutter -WORKDIR /app -COPY ./ui/flutter/pubspec.yaml ./ui/flutter/pubspec.lock ./ -RUN flutter pub get -COPY ./ui/flutter ./ -RUN flutter build web --web-renderer html - -FROM golang:1.21.6 AS go +FROM golang:1.22.6 AS go WORKDIR /app COPY ./go.mod ./go.sum ./ RUN go mod download COPY . . -COPY --from=flutter /app/build/web ./cmd/web/dist ARG VERSION=dev RUN CGO_ENABLED=0 go build -tags nosqlite,web \ -ldflags="-s -w -X github.com/GopeedLab/gopeed/pkg/base.Version=$VERSION -X github.com/GopeedLab/gopeed/pkg/base.InDocker=true" \ diff --git a/entrypoint.sh b/entrypoint.sh index 270cd465c..5543a1f03 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh chown -R ${PUID}:${PGID} /app