Skip to content

Commit 73e3929

Browse files
committed
chore(ui): build UI image in CI pipelines(#415):
* find a way to speed it up significantly: * run CI with `pnpm` package manager * cache and reuse dependencies * remove nodejs-sast, use semgrep instead * enable Docker buildkit * enable `ui_build_ce_image_dev` in CI/CD. * remove `manual` running * build image after merging into the master branch * fix linter warnings
1 parent ec59a7a commit 73e3929

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+17598
-122
lines changed

ui/.dockerignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
11
**/node_modules/**
2+
/.vscode/
3+
/.idea/
4+
/bin/
5+
/.git/
6+
**/build/**
7+
ui/node_modules/
8+
ui/packages/ce/node_modules/
9+
ui/packages/shared/node_modules/
10+
ui/packages/platform/node_modules/

ui/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
node_modules/
1919
build/
2020
src/npm-debug.log
21+
packages/**/.eslintcache
2122

2223
# Temporary files and dirs (vim, etc.)
2324
*.swp

ui/.gitlab-ci.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,30 @@ include:
99
changes:
1010
- ui/**/*
1111

12+
default:
13+
image: node:lts-alpine
14+
cache: &cache
15+
key: "$CI_COMMIT_REF_SLUG"
16+
paths:
17+
- .pnpm-store
18+
policy: pull
19+
1220
check-code-style:
1321
<<: *only_ui
1422
stage: test
15-
image: node:16.13.0
23+
before_script:
24+
- apk add --no-cache curl
25+
- curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm@7
26+
- pnpm config set store-dir /builds/postgres-ai/database-lab/.pnpm-store/
27+
1628
script:
17-
- npm --prefix ui/ ci -ws
18-
- npm --prefix ui/ run lint -w packages/ce
19-
- npm --prefix ui/ run lint -w packages/platform
29+
- pnpm --dir ui/ i
30+
- pnpm --dir ui/ --filter @postgres.ai/ce lint
31+
- pnpm --dir ui/ --filter @postgres.ai/platform lint
32+
interruptible: true
33+
cache:
34+
<<: *cache
35+
policy: push
2036

2137
semgrep-sast:
2238
stage: test

ui/.npmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
auto-install-peers=true
2+
strict-peer-dependencies=false

ui/package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@
66
"npm": ">=7"
77
},
88
"scripts": {
9+
"preinstall": "npx only-allow pnpm",
910
"start:platform": "source ./packages/platform/deploy/configs/production.sh && npm run start -w @postgres.ai/platform",
1011
"start:ce": "npm run start -w @postgres.ai/ce"
11-
},
12-
"workspaces": [
13-
"./packages/*"
14-
]
12+
}
1513
}

ui/packages/ce/.dockerignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
**/node_modules/**
2+
/.vscode/
3+
/.idea/
4+
/bin/
5+
/.git/
6+
**/build/**
7+
/ui/node_modules/
8+
/ui/packages/ce/node_modules/
9+
/ui/packages/shared/node_modules/
10+
/ui/packages/platform/node_modules/

ui/packages/ce/.gitlab-ci.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
script:
2525
- apk add --no-cache bash
2626
- bash ./ui/packages/ce/ci_docker_build_push.sh
27+
needs:
28+
- job: check-code-style
29+
artifacts: false
2730

2831
# Jobs.
2932
ui_build_ce_image_release:
@@ -57,4 +60,3 @@ ui_build_ce_image_dev:
5760
REGISTRY: "${CI_REGISTRY}"
5861
DOCKER_NAME: "registry.gitlab.com/postgres-ai/database-lab/ce-ui"
5962
TAGS: "${DOCKER_NAME}:${CI_COMMIT_REF_SLUG}"
60-
when: manual

ui/packages/ce/.npmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
auto-install-peers=true
2+
strict-peer-dependencies=false

ui/packages/ce/Dockerfile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,20 @@ WORKDIR /app
55

66
COPY ./ui/ .
77

8-
RUN npm ci -ws
8+
RUN --mount=type=bind,id=pnpm,source=.pnpm-store,target=/app/.pnpm-store
99

1010
ARG API_URL_PREFIX
1111
ENV REACT_APP_API_URL_PREFIX ${API_URL_PREFIX}
1212

1313
ARG WS_URL_PREFIX
1414
ENV REACT_APP_WS_URL_PREFIX ${WS_URL_PREFIX}
1515

16-
RUN npm run build -w @postgres.ai/ce
16+
RUN apk add --no-cache --update git && \
17+
npm i -g pnpm; \
18+
pnpm config set store-dir /app/.pnpm-store; \
19+
pnpm set verify-store-integrity false; \
20+
pnpm --filter @postgres.ai/ce i; \
21+
pnpm --filter @postgres.ai/ce build
1722

1823
# Run phase.
1924
FROM nginx:1.20.1-alpine as run

ui/packages/ce/ci_docker_build_push.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ for tag in "${ADDR[@]}"; do
2424
done
2525

2626
set -x
27-
docker build --build-arg API_URL_PREFIX=/api --build-arg WS_URL_PREFIX=/ws $tags_build --file ./ui/packages/ce/Dockerfile .
27+
DOCKER_BUILDKIT=1 docker build --build-arg API_URL_PREFIX=/api --build-arg WS_URL_PREFIX=/ws $tags_build --file ./ui/packages/ce/Dockerfile .
2828
set +x
2929

3030
echo -e "$tags_push" | while read -r tag; do

0 commit comments

Comments
 (0)