Skip to content

Commit

Permalink
chore(frontend): fix build script
Browse files Browse the repository at this point in the history
  • Loading branch information
634750802 committed Jul 22, 2024
1 parent c38cd22 commit db630c4
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 27 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Frontend
frontend/Dockerfile
frontend/**/node_modules
frontend/app/.next
frontend/app/.swc
frontend/packages/*/dist
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ services:
frontend:
image: tidb.ai/frontend:local
build:
context: ./frontend
context: .
dockerfile: frontend/Dockerfile
restart: always
ports:
- 3000:3000
Expand Down
8 changes: 0 additions & 8 deletions frontend/.dockerignore

This file was deleted.

33 changes: 19 additions & 14 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@ RUN apk add --no-cache libc6-compat

WORKDIR /tidb.ai

RUN mkdir app
RUN mkdir -p packages/widget-react
RUN mkdir -p frontend/app
RUN mkdir -p frontend/packages/widget-react

# Install dependencies based on the preferred package manager
COPY package.json .
COPY pnpm-*.yaml .
COPY app/package.json ./app
COPY packages/widget-react/package.json ./packages/widget-react
COPY README.md .
COPY frontend/package.json ./frontend
COPY frontend/pnpm-*.yaml ./frontend
COPY frontend/app/package.json ./frontend/app
COPY frontend/packages/widget-react/package.json ./frontend/packages/widget-react

WORKDIR /tidb.ai/frontend

RUN corepack enable pnpm
RUN pnpm i --frozen-lockfile
Expand All @@ -23,13 +26,17 @@ RUN pnpm i --frozen-lockfile
# 2. Rebuild the source code only when needed
FROM base AS builder
WORKDIR /tidb.ai
COPY --from=deps /tidb.ai/node_modules ./node_modules
COPY --from=deps /tidb.ai/app/node_modules ./app/node_modules
COPY --from=deps /tidb.ai/packages/widget-react/node_modules ./packages/widget-react/node_modules
COPY --from=deps /tidb.ai/frontend/node_modules ./frontend/node_modules
COPY --from=deps /tidb.ai/frontend/app/node_modules ./frontend/app/node_modules
COPY --from=deps /tidb.ai/frontend/packages/widget-react/node_modules ./frontend/packages/widget-react/node_modules
# For symbol link of root README.md
COPY . .

# This will do the trick, use the corresponding env file for each environment.
#COPY .env.production.sample .env.production

WORKDIR /tidb.ai/frontend

ENV BASE_URL ""
ENV NEXT_PUBLIC_BASE_URL ""
ENV SITE_URL ""
Expand All @@ -55,14 +62,12 @@ RUN adduser -S nextjs -u 1001

# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nextjs:nodejs /tidb.ai/app/.next/standalone .
COPY --from=builder --chown=nextjs:nodejs /tidb.ai/app/.next/static app/.next/static

COPY --from=builder /tidb.ai/app/public app/public
COPY --from=builder --chown=nextjs:nodejs /tidb.ai/frontend/app/.next/standalone .
COPY --from=builder --chown=nextjs:nodejs /tidb.ai/frontend/app/.next/static app/.next/static
COPY --from=builder /tidb.ai/frontend/app/public frontend/app/public

USER nextjs

EXPOSE 3000


CMD node app/server.js
1 change: 0 additions & 1 deletion frontend/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"scripts": {
"dev": "next dev --experimental-https",
"dev:local": "next dev",
"postinstall": "cp ../../README.md src/pages/docs/README.md",
"build": "next build && next-sitemap",
"build:standalone": "STANDALONE=1 next build --no-lint && next-sitemap",
"start": "next start",
Expand Down
2 changes: 0 additions & 2 deletions frontend/app/src/pages/docs/.gitignore

This file was deleted.

1 change: 1 addition & 0 deletions frontend/app/src/pages/docs/README.md
2 changes: 1 addition & 1 deletion frontend/app/theme.config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useRouter } from 'next/router';
import { useConfig, DocsThemeConfig, Link } from 'nextra-theme-docs';

let themeConfig: DocsThemeConfig = {
docsRepositoryBase: 'https://github.com/pingcap/tidb.ai/tree/main/www',
docsRepositoryBase: 'https://github.com/pingcap/tidb.ai/tree/main/frontend/app',
useNextSeoProps () {
return {
titleTemplate: '%s - RAG app by TiDB ',
Expand Down

0 comments on commit db630c4

Please sign in to comment.