diff --git a/.github/workflows/dashboard-ci.yaml b/.github/workflows/dashboard-ci.yaml index 41abd5cf40..7a5b4509bd 100644 --- a/.github/workflows/dashboard-ci.yaml +++ b/.github/workflows/dashboard-ci.yaml @@ -8,7 +8,7 @@ on: - 'Makefile' - 'docker/Makefile' - 'docker/dashboard.Dockerfile' - - 'dashboard-ui/*' + - 'dashboard-ui-v2/*' - 'cmd/dashboard/*' - 'pkg/dashboard/*' pull_request: @@ -18,7 +18,7 @@ on: - 'Makefile' - 'docker/Makefile' - 'docker/dashboard.Dockerfile' - - 'dashboard-ui/*' + - 'dashboard-ui-v2/*' - 'cmd/dashboard/*' - 'pkg/dashboard/*' @@ -28,17 +28,32 @@ jobs: steps: - name: Check out code uses: actions/checkout@v3 - - name: Set Node.js 18.18.0 - uses: actions/setup-node@v3 + - uses: pnpm/action-setup@v4 + name: Install pnpm with: - node-version: 18.18.0 - - name: Run install - uses: borales/actions-yarn@v4 + version: 9 + run_install: false + - name: Set Node.js 20 + uses: actions/setup-node@v4 with: - dir: dashboard-ui - cmd: install # will run `yarn install` command - - name: Build dashboard - run: make dashboard-dist - + node-version: 20 + cache: pnpm + - name: Get pnpm store directory + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + - uses: actions/cache@v4 + name: Setup pnpm cache + with: + path: ${{ env.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + - name: Install dependencies + run: cd dashboard-ui-v2 && pnpm install + - name: Lint dashboard + run: cd dashboard-ui-v2 && pnpm run lint + - name: Build dashboard + run: make dashboard-dist diff --git a/Makefile b/Makefile index 07c58665d3..b48585b46f 100644 --- a/Makefile +++ b/Makefile @@ -49,12 +49,12 @@ test-sanity: .PHONY: dashboard-dist dashboard-dist: - cd dashboard-ui && yarn run build + cd dashboard-ui-v2 && pnpm run build .PHONY: dashboard dashboard: mkdir -p bin - go build -tags=jsoniter -ldflags ${LDFLAGS} -o bin/juicefs-csi-dashboard ./cmd/dashboard/ + CGO_ENABLED=0 go build -tags=jsoniter -ldflags ${LDFLAGS} -o bin/juicefs-csi-dashboard ./cmd/dashboard/ .PHONY: dashboard-dev dashboard-dev: dashboard diff --git a/dashboard-ui-v2/src/utils/index.ts b/dashboard-ui-v2/src/utils/index.ts index 0213067f82..ddb8736494 100644 --- a/dashboard-ui-v2/src/utils/index.ts +++ b/dashboard-ui-v2/src/utils/index.ts @@ -271,9 +271,9 @@ export const omitPod = (pod: Pod) => { } export const scParameter = (sc: StorageClass) => { - let parameters: string[] = [] + const parameters: string[] = [] for (const key in sc.parameters) { - if (sc.parameters.hasOwnProperty(key)) { + if (Object.prototype.hasOwnProperty.call(sc.parameters, key)) { const value = sc.parameters[key] parameters.push(`${key}: ${value}`) } diff --git a/docker/Makefile b/docker/Makefile index 99cc3f9d27..bc4f0d0057 100644 --- a/docker/Makefile +++ b/docker/Makefile @@ -189,11 +189,11 @@ fuse-ee-image-4.0-buildx: ################# JuiceFS image for dashboard ####################### .PHONY: dashboard-build dashboard-build: - docker build --build-context project=../ --build-context ui=../dashboard-ui/ -f dashboard.Dockerfile \ + docker build --build-context project=../ --build-context ui=../dashboard-ui/ --build-context bin/=../bin/ -f dashboard.Dockerfile \ -t $(REGISTRY)/$(DASHBOARD_IMAGE):$(DASHBOARD_TAG) . docker push $(REGISTRY)/$(DASHBOARD_IMAGE):$(DASHBOARD_TAG) .PHONY: dashboard-buildx dashboard-buildx: - docker buildx build --build-context project=../ --build-context ui=../dashboard-ui/ -f dashboard.Dockerfile \ + docker buildx build --build-context project=../ --build-context ui=../dashboard-ui/ --build-context bin/=../bin/ -f dashboard.Dockerfile \ -t $(REGISTRY)/$(DASHBOARD_IMAGE):$(DASHBOARD_TAG) --platform linux/amd64,linux/arm64 . --push diff --git a/docker/dashboard.Dockerfile b/docker/dashboard.Dockerfile index 1d7e7d046b..d5abf3832f 100644 --- a/docker/dashboard.Dockerfile +++ b/docker/dashboard.Dockerfile @@ -12,20 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM golang:1.20-alpine as builder -ARG GOPROXY -ARG HTTPS_PROXY -ARG HTTP_PROXY -WORKDIR /workspace -COPY --from=project **/*.go ./ -COPY --from=project cmd ./cmd -COPY --from=project pkg ./pkg -COPY --from=project go.mod . -COPY --from=project go.sum . -COPY --from=project Makefile . -RUN apk add --no-cache make && make dashboard - FROM alpine:3.18 COPY --from=ui dist /dist -COPY --from=builder /workspace/bin/juicefs-csi-dashboard /usr/local/bin/juicefs-csi-dashboard +COPY --from=bin juicefs-csi-dashboard /usr/local/bin/juicefs-csi-dashboard ENTRYPOINT ["juicefs-csi-dashboard"]