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

build: improve build performance #386

Merged
merged 1 commit into from
Mar 4, 2024
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
12 changes: 9 additions & 3 deletions apps/api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@

# Copy source code and build the project
FROM node:18-alpine as builder
RUN apk add --no-cache git

WORKDIR /builder

COPY . .
RUN yarn install --silent

# Install dependencies only for the workspace needed
RUN yarn workspaces focus api @bandada/credentials @bandada/utils && \
yarn workspaces foreach -ptR --from '{api, libs/credentials, lib/utils}' run build && \
yarn workspaces focus api --production


# Create image for the app by copying build artifacts from builder
Expand All @@ -18,7 +22,9 @@ ARG PORT=3000
ENV NODE_ENV=production

WORKDIR /home/node/api
COPY --chown=node:node --from=builder /builder/ ./
COPY --chown=node:node --from=builder /builder/node_modules ./apps/node_modules
COPY --chown=node:node --from=builder /builder/apps/api ./apps/api
COPY --chown=node:node --from=builder /builder/libs ./apps/libs

EXPOSE ${PORT}
CMD ["node", "./apps/api/dist/main.js"]
2 changes: 1 addition & 1 deletion apps/api/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["node_modules", "dist", "**/*spec.ts"]
"exclude": ["node_modules", "dist", "**/*spec.ts", "**/*.test.ts"]
}
8 changes: 4 additions & 4 deletions apps/client/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# NOTE: This Dockerfile should be build with project root as context
# Sample: docker build -f ./apps/client/Dockerfile .

# Copy source code and build the project
FROM node:18-alpine as builder
RUN apk add --no-cache git

WORKDIR /builder

COPY . .
RUN yarn install --silent && yarn workspaces foreach -ptR --from '{client,libs}' run build

RUN yarn workspaces focus client @bandada/api-sdk @bandada/utils && \
yarn workspaces foreach -ptR --from '{client, libs/api-sdk, lib/utils}' run build


# Create image for the app by copying build artifacts from builder
Expand Down
3 changes: 2 additions & 1 deletion apps/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"@types/react-dom": "^18.0.10",
"@vitejs/plugin-react": "^3.1.0",
"typescript": "^4.9.3",
"vite": "^4.1.0"
"vite": "^4.1.0",
"vite-plugin-node-polyfills": "^0.20.0"
}
}
3 changes: 2 additions & 1 deletion apps/client/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import react from "@vitejs/plugin-react"
import { defineConfig } from "vite"
import { nodePolyfills } from "vite-plugin-node-polyfills"

// https://vitejs.dev/config/
export default defineConfig(() => ({
plugins: [react()]
plugins: [nodePolyfills(), react()]
}))
6 changes: 4 additions & 2 deletions apps/dashboard/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@

# Copy source code and build the project
FROM node:18-alpine as builder
RUN apk add --no-cache git

WORKDIR /builder

COPY . .
RUN yarn install --silent && yarn workspaces foreach -ptR --from '{dashboard,libs}' run build

# Install dependencies only for the workspace needed
RUN yarn workspaces focus dashboard @bandada/api-sdk @bandada/utils && \
yarn workspaces foreach -ptR --from '{dashboard, libs/credentials, libs/utils}' run build

# Create image for the app by copying build artifacts from builder
FROM nginx:stable-alpine as runner
Expand Down
3 changes: 3 additions & 0 deletions libs/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
"devDependencies": {
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-typescript": "^11.0.0",
"@types/jest": "29.4.0",
"@types/node": "18.11.18",
"jest": "29.4.3",
"rimraf": "^4.1.2",
"rollup": "^3.17.2",
"rollup-plugin-cleanup": "^3.2.1",
Expand Down
3 changes: 2 additions & 1 deletion libs/utils/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"baseUrl": ".",
"declarationDir": "./types"
},
"include": ["src"]
"include": ["src"],
"exclude": ["**/*.test.ts"]
}
Loading
Loading