Skip to content

Commit 67d6bdc

Browse files
authored
feat: simplify build of Next.js apps (#919)
1 parent 9b67666 commit 67d6bdc

File tree

14 files changed

+209
-191
lines changed

14 files changed

+209
-191
lines changed

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ jobs:
9696
username: ${{ github.actor }}
9797
password: ${{ secrets.GITHUB_TOKEN }}
9898

99-
- run: mise run beeai-server:build
99+
- run: mise run 'beeai-server:build:*'
100100
- uses: docker/build-push-action@v6
101101
with:
102102
context: ./apps/beeai-server
@@ -108,7 +108,8 @@ jobs:
108108
ghcr.io/${{ github.repository }}/beeai-server:${{ steps.version.outputs.latestTag }}
109109
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/beeai-server:cache
110110
cache-to: type=registry,ref=ghcr.io/${{ github.repository }}/beeai-server:cache,mode=max
111-
111+
112+
- run: mise run 'beeai-ui:build:*'
112113
- uses: docker/build-push-action@v6
113114
with:
114115
context: .
@@ -122,7 +123,6 @@ jobs:
122123
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/beeai-ui:cache
123124
cache-to: type=registry,ref=ghcr.io/${{ github.repository }}/beeai-ui:cache,mode=max
124125

125-
126126
- run: mise run helm:build
127127
- run: echo '${{ secrets.GITHUB_TOKEN }}' | helm registry login --username '${{ github.actor }}' --password-stdin ghcr.io
128128
- run: helm push ./helm/dist/beeai-platform-*.tgz 'oci://ghcr.io/${{ github.repository }}/beeai-platform-chart'

.github/workflows/web.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ jobs:
2525
registry: ghcr.io
2626
username: ${{ github.actor }}
2727
password: ${{ secrets.GITHUB_TOKEN }}
28+
- uses: ./.github/actions/setup
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
- run: mise run 'beeai-web:build:*'
2832
- uses: docker/build-push-action@v6
2933
with:
3034
context: .

apps/beeai-server/tasks.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,9 @@ run = "uv run beeai-server"
8484
# build
8585

8686
["beeai-server:build"]
87-
alias = "beeai-server:image:build"
8887
depends = ["beeai-server:build:*"]
8988
dir = "{{config_root}}/apps/beeai-server"
90-
run = "docker build -t ghcr.io/i-am-bee/beeai-platform/beeai-server:local . --load"
89+
run = "docker build -t ghcr.io/i-am-bee/beeai-platform/beeai-server:local --load ."
9190

9291
["beeai-server:build:requirements"]
9392
depends = ["beeai-server:setup"]

apps/beeai-ui/Dockerfile

Lines changed: 10 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,11 @@
1-
FROM node:23-alpine AS base
2-
3-
ENV PNPM_HOME="/pnpm"
4-
ENV PATH="$PNPM_HOME:$PATH"
5-
RUN corepack enable pnpm
6-
7-
FROM base AS builder
8-
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
9-
RUN apk add --no-cache libc6-compat
10-
WORKDIR /app
11-
12-
COPY pnpm-lock.yaml pnpm-workspace.yaml ./
13-
COPY ./apps/beeai-ui/package.json ./apps/beeai-ui/package.json
14-
15-
ENV NEXT_TELEMETRY_DISABLED=1
16-
ENV API_URL=http://localhost:8333
17-
18-
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm i --filter=@i-am-bee/beeai-ui --frozen-lockfile
19-
20-
COPY ./apps/beeai-ui ./apps/beeai-ui
21-
22-
RUN pnpm run -filter=@i-am-bee/beeai-ui build
23-
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm deploy --legacy --filter=@i-am-bee/beeai-ui --prod /prod/app
24-
RUN cp -r apps/beeai-ui/.next /prod/app/.next
25-
26-
FROM base AS runner
27-
WORKDIR /opt
28-
29-
ENV NODE_ENV=production
30-
31-
ENV NEXT_TELEMETRY_DISABLED=1
32-
33-
RUN addgroup --system --gid 1001 nodejs
34-
RUN adduser --system --uid 1001 nextjs
35-
36-
# Automatically leverage output traces to reduce image size
37-
# https://nextjs.org/docs/advanced-features/output-file-tracing
38-
COPY --from=builder --chown=nextjs:nodejs /prod/app/.next/standalone ./
39-
40-
WORKDIR /opt/apps/beeai-ui
41-
42-
COPY --from=builder --chown=nextjs:nodejs /prod/app/.next/static ./.next/static
43-
COPY --from=builder /prod/app/public ./public
44-
45-
USER nextjs
46-
1+
FROM node:22-alpine AS base
2+
COPY --chown=guest:guest ./apps/beeai-ui/.next/standalone /workspace/
3+
COPY --chown=guest:guest ./apps/beeai-ui/.next/static /workspace/apps/beeai-ui/.next/static
4+
COPY --chown=guest:guest ./apps/beeai-ui/public /workspace/apps/beeai-ui/.next/public
5+
USER guest
6+
ENV NEXT_TELEMETRY_DISABLED=1 \
7+
NODE_ENV=production \
8+
PORT=8334 \
9+
HOSTNAME="0.0.0.0"
10+
CMD ["node", "/workspace/apps/beeai-ui/server.js"]
4711
EXPOSE 8334
48-
49-
ENV PORT=8334
50-
51-
ENV HOSTNAME="0.0.0.0"
52-
CMD ["node", "server.js"]

apps/beeai-ui/package.json

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,6 @@
44
"private": true,
55
"version": "0.2.15-rc6",
66
"type": "module",
7-
"scripts": {
8-
"dev": "NODE_OPTIONS=\"--no-experimental-global-navigator\" next dev",
9-
"build": "NODE_OPTIONS=\"--no-experimental-global-navigator\" next build",
10-
"start": "pnpm build && NODE_OPTIONS=\"--no-experimental-global-navigator\" next start",
11-
"check": "prettier --log-level silent --check src && eslint src && tsc --noEmit -p tsconfig.json && stylelint src/**/*.css src/**/*.scss",
12-
"fix": "prettier --log-level silent --write src && eslint --fix src && stylelint --fix=lax src/**/*.css src/**/*.scss",
13-
"clean": "rm -rf node_modules && rm -rf dist",
14-
"schema:generate": "pnpm dlx openapi-typescript 'http://localhost:8333/api/v1/openapi.json' -o ./src/api/schema.d.ts --alphabetize"
15-
},
167
"exports": {
178
".": "./src/index.ts"
189
},
@@ -74,11 +65,11 @@
7465
"@next/eslint-plugin-next": "catalog:",
7566
"@svgr/webpack": "catalog:",
7667
"@types/hast": "^3.0.4",
77-
"@types/node": "^22.13.13",
7868
"@types/http-proxy": "^1.17.14",
7969
"@types/humanize-duration": "^3.27.4",
8070
"@types/lodash": "^4.17.16",
8171
"@types/mdast": "^4.0.4",
72+
"@types/node": "^22.13.13",
8273
"@types/pluralize": "^0.0.33",
8374
"@types/react": "^19.0.12",
8475
"@types/react-dom": "^19.0.4",
@@ -89,6 +80,7 @@
8980
"eslint-plugin-simple-import-sort": "catalog:",
9081
"globals": "catalog:",
9182
"keycode-js": "^3.1.0",
83+
"openapi-typescript": "^7.8.0",
9284
"openapi-typescript-helpers": "^0.0.15",
9385
"prettier": "catalog:",
9486
"sass-embedded": "catalog:",
@@ -99,5 +91,5 @@
9991
"typescript": "catalog:",
10092
"typescript-eslint": "catalog:"
10193
},
102-
"packageManager": "[email protected]+sha512.60c18acd138bff695d339be6ad13f7e936eea6745660d4cc4a776d5247c540d0edee1a563695c183a66eb917ef88f2b4feb1fc25f32a7adcadc7aaf3438e99c1"
103-
}
94+
"packageManager": "[email protected]"
95+
}

apps/beeai-ui/tasks.toml

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -60,41 +60,34 @@ outputs = { auto = true }
6060
# run
6161

6262
["beeai-ui:run"]
63-
description = "NOTE: You also need to have `beeai-server` running for the backend"
64-
depends = ["common:setup:pnpm"]
63+
depends = ["beeai-ui:build:nextjs"]
64+
env.NODE_OPTIONS = "--no-experimental-global-navigator"
6565
dir = "{{config_root}}/apps/beeai-ui"
66-
run = "pnpm dev"
67-
68-
# build
66+
run = "pnpm next start"
6967

70-
["beeai-ui:build:image"]
68+
["beeai-ui:run:dev"]
7169
depends = ["common:setup:pnpm"]
72-
dir = "{{config_root}}"
73-
run = "docker build -t ghcr.io/i-am-bee/beeai-platform/beeai-ui:local . -f ./apps/beeai-ui/Dockerfile --load"
70+
env.NODE_OPTIONS = "--no-experimental-global-navigator"
71+
dir = "{{config_root}}/apps/beeai-ui"
72+
run = "pnpm next dev"
7473

74+
# build
7575

7676
["beeai-ui:build"]
77-
depends = ["common:setup:pnpm"]
78-
dir = "{{config_root}}/apps/beeai-ui"
79-
run = "pnpm build"
80-
sources = ["*.json", "*.js", "src/**/*.tsx", "src/**/*.ts"]
81-
outputs = ["dist/**/*"]
82-
83-
# preview
77+
depends = ["beeai-ui:build:*"]
78+
dir = "{{config_root}}"
79+
run = "docker build -t ghcr.io/i-am-bee/beeai-platform/beeai-ui:local -f ./apps/beeai-ui/Dockerfile --load ."
8480

85-
["beeai-ui:start"]
81+
["beeai-ui:build:nextjs"]
8682
depends = ["common:setup:pnpm"]
8783
dir = "{{config_root}}/apps/beeai-ui"
88-
run = "pnpm start"
89-
90-
# clean
91-
92-
["beeai-ui:clean"]
93-
dir = "{{config_root}}/apps/beeai-ui"
94-
run = "rm -rf ./dist"
84+
env.NODE_OPTIONS = "--no-experimental-global-navigator"
85+
run = "pnpm next build"
86+
sources = ["*.json", "*.js", "*.mjs", "*.ts", "public/**/*", "src/**/*"]
87+
outputs = { auto = true }
9588

9689
# schema
9790

9891
["beeai-ui:schema:generate"]
9992
dir = "{{config_root}}/apps/beeai-ui"
100-
run = "pnpm schema:generate"
93+
run = "pnpm openapi-typescript 'http://localhost:8333/api/v1/openapi.json' -o ./src/api/schema.d.ts --alphabetize"

apps/beeai-web/Dockerfile

Lines changed: 10 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,11 @@
1-
FROM node:23-alpine AS base
2-
3-
ENV PNPM_HOME="/pnpm"
4-
ENV PATH="$PNPM_HOME:$PATH"
5-
RUN corepack enable pnpm
6-
7-
FROM base AS builder
8-
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
9-
RUN apk add --no-cache libc6-compat
10-
WORKDIR /app
11-
12-
COPY . .
13-
14-
ENV NEXT_TELEMETRY_DISABLED=1
15-
16-
RUN pnpm i --frozen-lockfile
17-
RUN pnpm run -r build
18-
RUN pnpm deploy --legacy --filter=@i-am-bee/beeai-web --prod /prod/app
19-
RUN cp -r apps/beeai-web/.next /prod/app/.next
20-
21-
FROM base AS runner
22-
WORKDIR /opt
23-
24-
ENV NODE_ENV=production
25-
26-
ENV NEXT_TELEMETRY_DISABLED=1
27-
28-
RUN addgroup --system --gid 1001 nodejs
29-
RUN adduser --system --uid 1001 nextjs
30-
31-
# Automatically leverage output traces to reduce image size
32-
# https://nextjs.org/docs/advanced-features/output-file-tracing
33-
COPY --from=builder --chown=nextjs:nodejs /prod/app/.next/standalone ./
34-
35-
WORKDIR /opt/apps/beeai-web
36-
37-
COPY --from=builder --chown=nextjs:nodejs /prod/app/.next/static ./.next/static
38-
COPY --from=builder /prod/app/public ./public
39-
40-
USER nextjs
41-
1+
FROM node:22-alpine AS base
2+
COPY --chown=guest:guest ./apps/beeai-web/.next/standalone /workspace/
3+
COPY --chown=guest:guest ./apps/beeai-web/.next/static /workspace/apps/beeai-web/.next/static
4+
COPY --chown=guest:guest ./apps/beeai-web/public /workspace/apps/beeai-web/.next/public
5+
USER guest
6+
ENV NEXT_TELEMETRY_DISABLED=1 \
7+
NODE_ENV=production \
8+
PORT=3000 \
9+
HOSTNAME="0.0.0.0"
10+
CMD ["node", "/workspace/apps/beeai-web/server.js"]
4211
EXPOSE 3000
43-
44-
ENV PORT=3000
45-
46-
ENV HOSTNAME="0.0.0.0"
47-
CMD ["node", "server.js"]

apps/beeai-web/package.json

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,6 @@
22
"name": "@i-am-bee/beeai-web",
33
"version": "0.2.15-rc6",
44
"private": true,
5-
"scripts": {
6-
"dev": "NODE_OPTIONS=\"--no-experimental-global-navigator\" next dev",
7-
"build": "NODE_OPTIONS=\"--no-experimental-global-navigator\" next build",
8-
"start": "NODE_OPTIONS=\"--no-experimental-global-navigator\" next start",
9-
"check": "prettier --log-level silent --check src && eslint src && tsc --noEmit -p tsconfig.json && stylelint src/**/*.css src/**/*.scss",
10-
"fix": "prettier --log-level silent --write src && eslint --fix src && stylelint --fix=lax src/**/*.css src/**/*.scss",
11-
"lint": "next lint"
12-
},
135
"peerDependencies": {
146
"@bprogress/next": "*",
157
"@carbon/icons-react": "*",
@@ -51,5 +43,5 @@
5143
"typescript": "catalog:",
5244
"typescript-eslint": "catalog:"
5345
},
54-
"packageManager": "[email protected]+sha512.60c18acd138bff695d339be6ad13f7e936eea6745660d4cc4a776d5247c540d0edee1a563695c183a66eb917ef88f2b4feb1fc25f32a7adcadc7aaf3438e99c1"
55-
}
46+
"packageManager": "[email protected]"
47+
}

apps/beeai-web/tasks.toml

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -67,29 +67,28 @@ outputs = { auto = true }
6767
# run
6868

6969
["beeai-web:run"]
70-
description = "NOTE: You also need to have `beeai-server` running for the backend"
70+
depends = ["beeai-web:build:nextjs"]
71+
env.NODE_OPTIONS = "--no-experimental-global-navigator"
72+
dir = "{{config_root}}/apps/beeai-web"
73+
run = "pnpm next start"
74+
75+
["beeai-web:run:dev"]
7176
depends = ["common:setup:pnpm"]
77+
env.NODE_OPTIONS = "--no-experimental-global-navigator"
7278
dir = "{{config_root}}/apps/beeai-web"
73-
run = "pnpm dev"
79+
run = "pnpm next dev"
7480

7581
# build
7682

7783
["beeai-web:build"]
78-
depends = ["common:setup:pnpm"]
79-
dir = "{{config_root}}/apps/beeai-web"
80-
run = "pnpm build"
81-
sources = ["*.json", "*.js", "src/**/*.tsx", "src/**/*.ts"]
82-
outputs = { auto = true }
84+
depends = ["beeai-web:build:*"]
85+
dir = "{{config_root}}"
86+
run = "docker build -t ghcr.io/i-am-bee/beeai-platform/beeai-web:local -f ./apps/beeai-web/Dockerfile --load ."
8387

84-
# preview
85-
86-
["beeai-web:start"]
88+
["beeai-web:build:nextjs"]
8789
depends = ["common:setup:pnpm"]
8890
dir = "{{config_root}}/apps/beeai-web"
89-
run = "pnpm start"
90-
91-
# clean
92-
93-
["beeai-web:clean"]
94-
dir = "{{config_root}}/apps/beeai-web"
95-
run = "rm -rf ./.next"
91+
env.NODE_OPTIONS = "--no-experimental-global-navigator"
92+
run = "pnpm next build"
93+
sources = ["*.json", "*.js", "*.mjs", "*.ts", "public/**/*", "src/**/*"]
94+
outputs = { auto = true }

docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"keywords": [],
1111
"author": "IBM Corp.",
1212
"license": "ISC",
13-
"packageManager": "[email protected]+sha512.60c18acd138bff695d339be6ad13f7e936eea6745660d4cc4a776d5247c540d0edee1a563695c183a66eb917ef88f2b4feb1fc25f32a7adcadc7aaf3438e99c1",
13+
"packageManager": "[email protected]",
1414
"devDependencies": {
1515
"mintlify": "^4.1.97"
1616
}

0 commit comments

Comments
 (0)