Skip to content
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

perf(frontend): perf build speed #4013

Merged
merged 1 commit into from
Oct 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions .github/workflows/frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
matrix:
module:
[
providers/license,
providers/license,
providers/cronjob,
providers/template,
providers/adminer,
Expand Down Expand Up @@ -105,7 +105,15 @@ jobs:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GH_PAT }}

- name: Cache pnpm-store
uses: actions/cache@v3
with:
path: pnpm-store
key: pnpm-store-${{ hashFiles('Dockerfile') }}
- name: inject pnpm-store into docker
uses: reproducible-containers/[email protected]
with:
cache-source: pnpm-store
- name: Build And Push
uses: docker/build-push-action@v4
with:
Expand All @@ -119,6 +127,8 @@ jobs:
push: ${{ (github.event_name == 'push') ||(github.event_name == 'create') || (inputs.push_image == true) }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
save-sealos:
uses: ./.github/workflows/import-save-sealos.yml
cluster-image-build:
Expand All @@ -131,7 +141,7 @@ jobs:
matrix:
module:
[
providers/license,
providers/license,
providers/cronjob,
providers/template,
providers/adminer,
Expand Down
2 changes: 1 addition & 1 deletion docs/website/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const config = {
},
{
position: "left",
to: "https://www.wenjuan.com/s/UZBZJv9ToJ/#",
to: "https://fael3z0zfze.feishu.cn/share/base/form/shrcnesSfEK65JZaAf2W6Fwz6Ad",
label: "Contact",
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/website/src/pages/components/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const navbar = [
{
key: 'contact',
label: <Translate>Contact</Translate>,
to: 'https://www.wenjuan.com/s/UZBZJv9ToJ/#',
to: 'https://fael3z0zfze.feishu.cn/share/base/form/shrcnesSfEK65JZaAf2W6Fwz6Ad',
},
]

Expand Down
1 change: 1 addition & 0 deletions frontend/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
git-branch-lockfiles=true
35 changes: 14 additions & 21 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FROM node:current-alpine As base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"

FROM node:current-alpine AS runner
FROM base AS runner
WORKDIR /app

ENV NODE_ENV production
Expand All @@ -21,13 +24,6 @@ ENV NEXT_TELEMETRY_DISABLED 1

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
ARG mirror
RUN if [ "$mirror" = "tsinghua"]; then \
echo "MIRROR: $mirror"; \
sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories; \
else \
sed -i 's/https/http/' /etc/apk/repositories; \
fi

RUN apk add curl \
&& apk add ca-certificates \
Expand All @@ -46,7 +42,7 @@ EXPOSE 3000

ENV PORT 3000
# Install dependencies only when needed
FROM node:current-alpine AS deps
FROM base AS deps

# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat && npm install -g pnpm
Expand All @@ -55,45 +51,42 @@ WORKDIR /app
# Install dependencies based on the preferred package manager root workspace
COPY pnpm-lock.yaml package.json pnpm-workspace.yaml ./

RUN \
RUN --mount=type=cache,id=pnpm,target=/pnpm/store \
[ -f pnpm-lock.yaml ] && pnpm fetch || \
(echo "Lockfile not found." && exit 1)
COPY ./tsconfig.json ./tsconfig.json
COPY ./tsconfig.deps.json ./tsconfig.deps.json
COPY ./tsconfig.base.json ./tsconfig.base.json
COPY ./packages ./packages

RUN pnpm -r --offline --filter=./packages/* install \
RUN --mount=type=cache,id=pnpm,target=/pnpm/store \
pnpm -r --offline --filter=./packages/* install \
&& pnpm -r --filter=./packages/* run build

# Rebuild the source code only when needed
FROM node:current-alpine AS builder
FROM deps AS builder

WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
# COPY --from=deps /app/packages ./packages
# COPY --from=deps /app/node_modules ./node_modules
# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry during the build.
ENV NEXT_TELEMETRY_DISABLED 1

RUN npm install -g pnpm
# RUN npm install -g pnpm


COPY --from=deps /app/packages ./packages
# COPY --from=deps /app/packages ./packages

COPY . .
# RUN pnpm -r --offline --filter=./packages/* install \
# && pnpm -r --filter=./packages/* run build


ARG name
ARG path

RUN pnpm --offline --filter=$name install && pnpm --filter=$name run build
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm --offline --filter=$name install && pnpm --filter=$name run build

# Production image, copy all the files and run next
FROM runner
FROM runner As runner

ARG name
ARG path
Expand Down
5 changes: 2 additions & 3 deletions frontend/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
DOCKER_USERNAME := $(DOCKER_USERNAME)
IMAGE_TAG := $(IMAGE_TAG)
MIRROR := $(MIRROR)

ifneq ($(strip $(DOCKER_USERNAME)),)
imageOwner := $(DOCKER_USERNAME)/
Expand Down Expand Up @@ -61,9 +60,9 @@ image-prebuild: pnpm-lock.yaml
docker build --platform=linux/amd64 --target deps . -t $(imageOwner)sealos-deps:dev

image-build-providers/%: image-prebuild
docker build --platform=linux/amd64 -t $(imageOwner)sealos-$*:$(imageTag) --build-arg path=providers/$* --build-arg name=$* --build-arg mirror=$(MIRROR) .
docker build --platform=linux/amd64 -t $(imageOwner)sealos-$*:$(imageTag) --build-arg path=providers/$* --build-arg name=$* .
image-build-%: image-prebuild
docker build --platform=linux/amd64 -t $(imageOwner)sealos-$*:$(imageTag) --build-arg path=$* --build-arg name=$* --build-arg mirror=$(MIRROR) .
docker build --platform=linux/amd64 -t $(imageOwner)sealos-$*:$(imageTag) --build-arg path=$* --build-arg name=$* .

image-push-providers/%: image-build-providers/%
docker push $(imageOwner)sealos-$*:$(imageTag)
Expand Down
44 changes: 22 additions & 22 deletions frontend/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,25 @@
"@alicloud/dysmsapi20170525": "^2.0.24",
"@alicloud/openapi-client": "^0.4.6",
"@alicloud/tea-util": "^1.4.7",
"@chakra-ui/react": "^2.8.0",
"@chakra-ui/react": "^2.8.1",
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@kubernetes/client-node": "^0.18.1",
"@tanstack/react-query": "^4.29.25",
"axios": "^1.4.0",
"@tanstack/react-query": "^4.35.3",
"axios": "^1.5.1",
"clsx": "^1.2.1",
"cors": "^2.8.5",
"dayjs": "^1.11.9",
"dayjs": "^1.11.10",
"eslint": "8.38.0",
"eslint-config-next": "13.3.0",
"framer-motion": "^10.12.22",
"framer-motion": "^10.16.4",
"i18next": "^22.5.1",
"immer": "^10.0.2",
"js-cookie": "^3.0.5",
"js-yaml": "^4.1.0",
"jsonwebtoken": "^9.0.1",
"jsonwebtoken": "^9.0.2",
"lodash": "^4.17.21",
"mongodb": "^5.7.0",
"mongodb": "^5.9.0",
"nanoid": "^4.0.2",
"next": "13.3.0",
"next-i18next": "^13.3.0",
Expand All @@ -41,29 +41,29 @@
"qrcode.react": "^3.1.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-draggable": "^4.4.5",
"react-hook-form": "^7.45.2",
"react-draggable": "^4.4.6",
"react-hook-form": "^7.46.2",
"react-i18next": "^12.3.1",
"sass": "^1.63.6",
"sass": "^1.68.0",
"sealos-desktop-sdk": "workspace:*",
"uuid": "^9.0.0",
"zustand": "^4.3.9"
"uuid": "^9.0.1",
"zustand": "^4.4.1"
},
"devDependencies": {
"@testing-library/jest-dom": "^6.1.2",
"@testing-library/jest-dom": "^6.1.3",
"@testing-library/react": "^14.0.0",
"@types/jest": "^29.5.4",
"@types/js-cookie": "^3.0.3",
"@types/js-yaml": "^4.0.5",
"@types/jsonwebtoken": "^9.0.2",
"@types/lodash": "^4.14.195",
"@types/jest": "^29.5.5",
"@types/js-cookie": "^3.0.4",
"@types/js-yaml": "^4.0.6",
"@types/jsonwebtoken": "^9.0.3",
"@types/lodash": "^4.14.199",
"@types/node": "18.15.11",
"@types/nprogress": "^0.2.0",
"@types/nprogress": "^0.2.1",
"@types/react": "18.0.37",
"@types/react-dom": "18.0.11",
"@types/uuid": "^9.0.2",
"jest": "^29.6.4",
"jest-environment-jsdom": "^29.6.4",
"@types/uuid": "^9.0.4",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"prettier": "^2.8.8"
}
}
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
"react-i18next": "^12.3.1"
},
"dependencies": {
"typescript": "^5.1.6"
"typescript": "^5.2.2"
}
}
20 changes: 10 additions & 10 deletions frontend/packages/client-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,22 @@
"author": "[email protected]",
"license": "ISC",
"devDependencies": {
"@rollup/plugin-typescript": "^11.1.2",
"@types/js-cookie": "^3.0.3",
"@types/js-yaml": "^4.0.5",
"@types/node": "^20.5.7",
"@types/uuid": "^9.0.2",
"@rollup/plugin-typescript": "^11.1.4",
"@types/js-cookie": "^3.0.4",
"@types/js-yaml": "^4.0.6",
"@types/node": "^20.7.1",
"@types/uuid": "^9.0.4",
"rollup": "2.79.1",
"rollup-plugin-copy": "^3.4.0",
"rollup-plugin-copy": "^3.5.0",
"rollup-plugin-dts": "^4.2.3",
"tslib": "^2.6.0"
"tslib": "^2.6.2"
},
"dependencies": {
"@kubernetes/client-node": "^0.18.1",
"axios": "^1.4.0",
"dayjs": "^1.11.9",
"axios": "^1.5.1",
"dayjs": "^1.11.10",
"js-cookie": "^3.0.5",
"js-yaml": "^4.1.0",
"uuid": "^9.0.0"
"uuid": "^9.0.1"
}
}
Loading