-
Notifications
You must be signed in to change notification settings - Fork 82
feat: add Bun support #1531
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
base: main
Are you sure you want to change the base?
feat: add Bun support #1531
Changes from all commits
29e4b04
5e6a2c3
89b5d55
fc884d2
c3a662c
764a872
79fd9ce
3f50e23
34de9a1
a696931
dcae694
7f15b01
3fc3c78
dfa8b5e
6cb498a
29780a0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,57 +1,52 @@ | ||
| # Stage 1: Build the application | ||
| FROM node:24-alpine3.21 AS build | ||
| FROM oven/bun:1.3-alpine AS build | ||
| # Install OpenSSL | ||
| RUN apk update && apk upgrade | ||
| RUN apk add --no-cache openssl | ||
| RUN set -eux \ | ||
| && apk --no-cache add \ | ||
| openssh-client \ | ||
| aws-cli \ | ||
| docker \ | ||
| docker-compose \ | ||
| jq \ | ||
| && npm install -g pnpm --ignore-scripts \ | ||
| && export PATH=$PATH:/usr/lib/node_modules/pnpm/bin \ | ||
| && rm -rf /var/cache/apk/* | ||
| RUN apk update && apk upgrade && apk add --no-cache \ | ||
| openssl \ | ||
| openssh-client \ | ||
| aws-cli \ | ||
| docker \ | ||
| docker-compose \ | ||
| jq | ||
|
|
||
| # Set the working directory | ||
| WORKDIR /app | ||
|
|
||
| # Copy package.json and package-lock.json | ||
| COPY package.json ./ | ||
| COPY bun.lock ./ | ||
| COPY pnpm-workspace.yaml ./ | ||
|
|
||
| ENV PUPPETEER_SKIP_DOWNLOAD=true | ||
|
|
||
| # Install dependencies while ignoring scripts (including Puppeteer's installation) | ||
| RUN pnpm i --ignore-scripts | ||
| RUN bun install | ||
|
|
||
| # Copy the rest of the application code | ||
| COPY . . | ||
|
|
||
| # Generate Prisma client | ||
| # RUN cd libs/prisma-service && npx prisma migrate deploy && npx prisma generate | ||
| RUN cd libs/prisma-service && npx prisma generate | ||
| RUN cd libs/prisma-service && bunx prisma generate | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Verify Node.js availability in the Dockerfile build environment. Prisma works out of the box with Bun, and Node.js must be installed in the environment where you're running bunx prisma commands. While bunx prisma generate is the official approach, Docker builds with Bun have reported compatibility issues. Ensure your build image includes Node.js, or consider pre-generating the Prisma client locally and shipping it with the image. If using a Bun-only base image (e.g., 🤖 Prompt for AI Agents |
||
| RUN ls -R /app/apps/agent-provisioning/AFJ/ | ||
|
|
||
| # Build the user service | ||
| RUN pnpm run build agent-provisioning | ||
| RUN bun --bun run build agent-provisioning | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Check packageManager configuration
echo "=== Package Manager Configuration ==="
head -20 package.json | grep -A2 '"packageManager"'
echo ""
# Check build-related scripts in package.json
echo "=== Build Scripts ==="
grep -A30 '"scripts"' package.json | grep -i build
echo ""
# Look for Dockerfile and related build context
echo "=== Checking Dockerfile structure ==="
head -50 Dockerfiles/Dockerfile.agent-provisioning
echo ""
# Search for agent-provisioning build configuration
echo "=== Looking for agent-provisioning build config ==="
find . -path ./node_modules -prune -o -name "tsconfig.json" -o -name "nx.json" -o -name "project.json" 2>/dev/null | head -20
echo ""
# Check if there are any build or monorepo configuration files
ls -la | grep -E 'nx\.json|turbo\.json|lerna\.json|pnpm-workspace|workspace' 2>/dev/null
echo ""
# Search for Node-specific APIs in agent-provisioning
echo "=== Searching for Node.js-specific patterns ==="
rg 'process\.(binding|_rawDebug|_tickCallback|env|argv|versions\[|_eval)|require\.extensions|module\._compile|Buffer\.|stream\.|crypto\.|fs\.|path\.|url\.' apps/agent-provisioning --type ts --type js -c 2>/dev/null | head -20Repository: credebl/platform Length of output: 1948 🏁 Script executed: #!/bin/bash
# Get more details about the Node-specific API usage
echo "=== Checking actual imports in agent-provisioning ==="
head -20 apps/agent-provisioning/src/agent-provisioning.service.ts
head -20 apps/agent-provisioning/src/main.ts
head -20 apps/agent-provisioning/src/agent-provisioning.module.ts
echo ""
# Check the actual build script definition
echo "=== Complete package.json scripts section ==="
sed -n '/"scripts"/,/^[[:space:]]*}/p' package.json | grep -E '(build|test)' | head -30
echo ""
# Check if there's a nest config or build config for agent-provisioning
echo "=== NestJS configuration files ==="
find apps/agent-provisioning -maxdepth 2 -name "*.json" -o -name "*.config.*" 2>/dev/null | head -20
echo ""
# Check package.json for agent-provisioning workspace
echo "=== Package.json structure ==="
grep -n '"name"' package.json | head -5
echo ""
# Check if there's a workspace for agent-provisioning
cat pnpm-workspace.yamlRepository: credebl/platform Length of output: 4147 🏁 Script executed: #!/bin/bash
# Check if there's a specific build script for agent-provisioning in its own package.json
echo "=== Checking agent-provisioning package.json if exists ==="
if [ -f "apps/agent-provisioning/package.json" ]; then
cat apps/agent-provisioning/package.json | grep -A50 '"scripts"' | head -60
else
echo "No separate package.json in agent-provisioning"
fi
echo ""
# Check the complete tsconfig for agent-provisioning
echo "=== agent-provisioning tsconfig ==="
cat apps/agent-provisioning/tsconfig.app.json
echo ""
# Verify what "build agent-provisioning" command refers to in root package.json
echo "=== Root package.json complete content (around build scripts) ==="
sed -n '1,100p' package.json | grep -A2 '"build"'
echo ""
# Check if there are any Bun-specific configurations
echo "=== Checking for bunfig.toml or bun config ==="
ls -la bunfig.toml bun.config.* 2>/dev/null || echo "No bun config files found"
echo ""
# Check if the Dockerfile.agent-provisioning is the only one or if there's a pattern
echo "=== Checking all Dockerfiles ==="
ls -la Dockerfiles/Repository: credebl/platform Length of output: 2038 🏁 Script executed: #!/bin/bash
# Check if "build agent-provisioning" is a NestJS CLI command or if it's supposed to be "nest build agent-provisioning"
echo "=== Checking NestJS nest-cli.json for project config ==="
if [ -f "nest-cli.json" ]; then
cat nest-cli.json
else
echo "No nest-cli.json found"
fi
echo ""
# Check all Dockerfiles to see how other services handle build
echo "=== Comparing build commands across Dockerfiles ==="
grep -h "RUN.*run build\|RUN.*run nest build" Dockerfiles/* 2>/dev/null || echo "No matching build commands found in other Dockerfiles"
echo ""
# Check if there's a workspace or projects configuration
echo "=== Checking tsconfig root ==="
cat tsconfig.json | head -50
echo ""
# Verify the exact bun command syntax - does "bun --bun run build agent-provisioning" work?
echo "=== Checking Bun documentation reference in comments ==="
head -100 Dockerfiles/Dockerfile.agent-provisioning | grep -i "bun\|run\|build"Repository: credebl/platform Length of output: 11697 Remove The 🤖 Prompt for AI Agents |
||
|
|
||
| # Stage 2: Create the final image | ||
| FROM node:24-alpine3.21 | ||
| FROM oven/bun:1.3-alpine AS prod | ||
| # Install OpenSSL | ||
| RUN apk update && apk upgrade | ||
| RUN apk add --no-cache openssl | ||
| RUN set -eux \ | ||
| && apk --no-cache add \ | ||
| openssh-client \ | ||
| aws-cli \ | ||
| docker \ | ||
| docker-compose \ | ||
| jq \ | ||
| && npm install -g pnpm --ignore-scripts \ | ||
| && export PATH=$PATH:/usr/lib/node_modules/pnpm/bin \ | ||
| && rm -rf /var/cache/apk/* | ||
| RUN apk update && apk upgrade && apk add --no-cache \ | ||
| openssl \ | ||
| openssh-client \ | ||
| aws-cli \ | ||
| docker \ | ||
| docker-compose \ | ||
| jq | ||
|
Comment on lines
41
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major Remove redundant Same issue as the build stage: lines 41-42 are redundant since lines 43-49 perform another 🔎 Apply this diff to consolidate: # Stage 2: Create the final image
FROM oven/bun:1.1-alpine AS prod
-# Install OpenSSL
-RUN apk update && apk upgrade
-RUN apk add --no-cache openssl
+# Install required packages
RUN apk update && apk upgrade && apk add --no-cache \
openssl \
openssh-client \
aws-cli \
docker \
docker-compose \
jq
🤖 Prompt for AI Agents |
||
|
|
||
| WORKDIR /app | ||
|
|
||
|
|
@@ -80,4 +75,4 @@ RUN chmod 777 /app/agent-provisioning/AFJ/token | |
| COPY libs/ ./libs/ | ||
|
|
||
| # Set the command to run the microservice | ||
| CMD ["sh", "-c", "cd libs/prisma-service && npx prisma migrate deploy && npx prisma generate && cd ../.. && node dist/apps/agent-provisioning/main.js"] | ||
| CMD ["sh", "-c", "cd libs/prisma-service && bunx prisma migrate deploy && bunx prisma generate && cd ../.. && bun --bun dist/apps/agent-provisioning/main.js"] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,37 @@ | ||
| # Stage 1: Build the application | ||
| FROM node:24-alpine3.21 AS build | ||
| FROM oven/bun:1.3-alpine AS build | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: cat Dockerfiles/Dockerfile.agent-serviceRepository: credebl/platform Length of output: 1694 🏁 Script executed: cat Dockerfiles/Dockerfile.agent-serviceRepository: credebl/platform Length of output: 1694 🏁 Script executed: find . -name "Dockerfile.agent-service" -type fRepository: credebl/platform Length of output: 98 Consolidate Bun version and remove pnpm from final stage. Bun 1.3 is current (latest 1.3.5), but address two critical issues:
🤖 Prompt for AI Agents |
||
| # Install OpenSSL | ||
| RUN apk update && apk upgrade && apk add --no-cache \ | ||
| openssl \ | ||
| openssh-client \ | ||
| aws-cli \ | ||
| docker \ | ||
| docker-compose \ | ||
| && rm -rf /var/cache/apk/* | ||
| RUN npm install -g pnpm@9.15.3 --ignore-scripts | ||
| docker-compose | ||
|
|
||
| # Set the working directory | ||
| WORKDIR /app | ||
| COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./ | ||
|
|
||
| # Copy package.json and package-lock.json | ||
| COPY package.json ./ | ||
| COPY bun.lock ./ | ||
| COPY pnpm-workspace.yaml ./ | ||
|
|
||
| ENV PUPPETEER_SKIP_DOWNLOAD=true | ||
| RUN pnpm i --frozen-lockfile --ignore-scripts | ||
|
|
||
| # Install dependencies while ignoring scripts (including Puppeteer's installation) | ||
| RUN bun install | ||
|
|
||
| # Copy the rest of the application code | ||
| COPY . . | ||
| RUN cd libs/prisma-service && npx prisma generate | ||
| RUN pnpm run build agent-service | ||
| RUN pnpm prune --prod | ||
| # RUN cd libs/prisma-service && npx prisma migrate deploy && npx prisma generate | ||
| RUN cd libs/prisma-service && bunx prisma generate | ||
|
|
||
| # Build the user service | ||
| RUN bun --bun run build agent-service | ||
|
|
||
| # Stage 2: Create the final image | ||
| FROM node:24-alpine3.21 | ||
| FROM oven/bun:1.3-alpine | ||
| # Install OpenSSL | ||
| RUN apk update && apk upgrade && apk add --no-cache \ | ||
| openssl \ | ||
| openssh-client \ | ||
|
|
@@ -28,9 +41,14 @@ RUN apk update && apk upgrade && apk add --no-cache \ | |
| && rm -rf /var/cache/apk/* \ | ||
| && addgroup -g 1001 -S nodejs \ | ||
| && adduser -S nextjs -u 1001 | ||
| # RUN npm install -g pnpm | ||
| # Set the working directory | ||
| WORKDIR /app | ||
| COPY --from=build /app/dist/apps/agent-service/ ./dist/apps/agent-service/ | ||
| COPY --from=build /app/libs/ ./libs/ | ||
| COPY --from=build /app/node_modules ./node_modules | ||
| #COPY --from=build /app/package.json ./ | ||
| COPY --from=build /app/node_modules ./node_modules | ||
| USER nextjs | ||
| CMD ["sh", "-c", "cd libs/prisma-service && npx prisma migrate deployy && cd ../.. && node dist/apps/agent-service/main.js"] | ||
|
|
||
| # Set the command to run the microservice | ||
| CMD ["sh", "-c", "cd libs/prisma-service && bunx prisma migrate deploy && bunx prisma generate && cd ../.. && bun --bun dist/apps/agent-service/main.js"] | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,26 +1,44 @@ | ||||||||||||||||||||||||||||||||||||||||
| # Stage 1: Build the application | ||||||||||||||||||||||||||||||||||||||||
| FROM node:24-alpine3.21 AS build | ||||||||||||||||||||||||||||||||||||||||
| FROM oven/bun:1.3-alpine as build | ||||||||||||||||||||||||||||||||||||||||
|
Check warning on line 2 in Dockerfiles/Dockerfile.api-gateway
|
||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use uppercase -FROM oven/bun:1.3-alpine as build
+FROM oven/bun:1.3-alpine AS build🧰 Tools🪛 GitHub Check: SonarCloud Code Analysis[warning] 2-2: Replace "as" with upper case format "AS". 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||
| # Install OpenSSL | ||||||||||||||||||||||||||||||||||||||||
| RUN apk update && apk upgrade && apk add --no-cache openssl \ | ||||||||||||||||||||||||||||||||||||||||
| && rm -rf /var/cache/apk/* | ||||||||||||||||||||||||||||||||||||||||
| RUN npm install -g pnpm@9.15.3 --ignore-scripts | ||||||||||||||||||||||||||||||||||||||||
| # Set the working directory | ||||||||||||||||||||||||||||||||||||||||
| WORKDIR /app | ||||||||||||||||||||||||||||||||||||||||
| COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./ | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| # Copy package.json and package-lock.json | ||||||||||||||||||||||||||||||||||||||||
| COPY package.json ./ | ||||||||||||||||||||||||||||||||||||||||
| COPY bun.lock ./ | ||||||||||||||||||||||||||||||||||||||||
| COPY pnpm-workspace.yaml ./ | ||||||||||||||||||||||||||||||||||||||||
| # COPY package-lock.json ./ | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| ENV PUPPETEER_SKIP_DOWNLOAD=true | ||||||||||||||||||||||||||||||||||||||||
| RUN pnpm i --frozen-lockfile --ignore-scripts | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| # Install dependencies while ignoring scripts (including Puppeteer's installation) | ||||||||||||||||||||||||||||||||||||||||
| RUN bun install | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+9
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use Consistent with the other Dockerfiles: pin install to the lockfile and remove the now-redundant pnpm workspace file (workspaces moved to root 🔧 Proposed fix COPY package.json ./
COPY bun.lock ./
-COPY pnpm-workspace.yaml ./
-# COPY package-lock.json ./
ENV PUPPETEER_SKIP_DOWNLOAD=true
-RUN bun install
+RUN bun install --frozen-lockfile📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| # Copy the rest of the application code | ||||||||||||||||||||||||||||||||||||||||
| COPY . . | ||||||||||||||||||||||||||||||||||||||||
| RUN cd libs/prisma-service && npx prisma generate | ||||||||||||||||||||||||||||||||||||||||
| RUN pnpm run build api-gateway | ||||||||||||||||||||||||||||||||||||||||
| RUN pnpm prune --prod | ||||||||||||||||||||||||||||||||||||||||
| # RUN cd libs/prisma-service && npx prisma migrate deploy && npx prisma generate | ||||||||||||||||||||||||||||||||||||||||
| RUN cd libs/prisma-service && bunx prisma generate | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| # Build the api-gateway service | ||||||||||||||||||||||||||||||||||||||||
| RUN bun --bun run build api-gateway | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| # Stage 2: Create the final image | ||||||||||||||||||||||||||||||||||||||||
| FROM node:24-alpine3.21 | ||||||||||||||||||||||||||||||||||||||||
| FROM oven/bun:1.3-alpine | ||||||||||||||||||||||||||||||||||||||||
| # Install OpenSSL | ||||||||||||||||||||||||||||||||||||||||
| RUN apk update && apk upgrade && apk add --no-cache openssl \ | ||||||||||||||||||||||||||||||||||||||||
| && rm -rf /var/cache/apk/* \ | ||||||||||||||||||||||||||||||||||||||||
| && addgroup -g 1001 -S nodejs \ | ||||||||||||||||||||||||||||||||||||||||
| && adduser -S nextjs -u 1001 | ||||||||||||||||||||||||||||||||||||||||
| # Set the working directory | ||||||||||||||||||||||||||||||||||||||||
| WORKDIR /app | ||||||||||||||||||||||||||||||||||||||||
| COPY --from=build /app/dist/apps/api-gateway/ ./dist/apps/api-gateway/ | ||||||||||||||||||||||||||||||||||||||||
| COPY --from=build /app/libs/ ./libs/ | ||||||||||||||||||||||||||||||||||||||||
| COPY --from=build /app/node_modules ./node_modules | ||||||||||||||||||||||||||||||||||||||||
| COPY --from=build /app/node_modules ./node_modules | ||||||||||||||||||||||||||||||||||||||||
| # COPY --from=build /app/uploadedFiles ./uploadedFiles | ||||||||||||||||||||||||||||||||||||||||
| USER nextjs | ||||||||||||||||||||||||||||||||||||||||
| CMD ["sh", "-c", "cd libs/prisma-service && npx prisma migrate deploy && cd ../.. && node dist/apps/api-gateway/main.js"] | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| # Set the command to run the microservice | ||||||||||||||||||||||||||||||||||||||||
| CMD ["sh", "-c", "cd libs/prisma-service && bunx prisma migrate deploy && bunx prisma generate && cd ../.. && bun --bun dist/apps/api-gateway/main.js"] | ||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result: No, NestJS is not officially supported on the Bun runtime in 2025 or as of 2026-05-06. NestJS maintainers have explicitly stated they focus on Node.js and will not tweak the framework specifically for Bun, though it may work due to Bun's Node.js compatibility claims [1]. Bun maintainers confirm NestJS "works in Bun" for core functionality but advise filing issues for specific library incompatibilities [2]. For the specified packages: - Citations:
Switch to Node runtime or comprehensively test Bun support before shipping. Using
If Bun runtime is intentional, verify the API gateway end-to-end (HTTP + WebSocket, microservice NATS transport, Bull jobs, persistence with PostgreSQL). Otherwise, use 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,26 +1,43 @@ | ||
| # Stage 1: Build the application | ||
| FROM node:24-alpine3.21 AS build | ||
| FROM oven/bun:1.3-alpine AS build | ||
| # Install OpenSSL | ||
| RUN apk update && apk upgrade && apk add --no-cache openssl \ | ||
| && rm -rf /var/cache/apk/* | ||
| RUN npm install -g pnpm@9.15.3 --ignore-scripts | ||
| # Set the working directory | ||
| WORKDIR /app | ||
| COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./ | ||
|
|
||
| # Copy package.json and package-lock.json | ||
| COPY package.json ./ | ||
| COPY bun.lock ./ | ||
| COPY pnpm-workspace.yaml ./ | ||
|
|
||
| ENV PUPPETEER_SKIP_DOWNLOAD=true | ||
| RUN pnpm i --frozen-lockfile --ignore-scripts | ||
|
|
||
| # Install dependencies while ignoring scripts (including Puppeteer's installation) | ||
| RUN bun install | ||
|
Comment on lines
+9
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use Same concerns as 🔧 Proposed fix # Copy package.json and package-lock.json
COPY package.json ./
COPY bun.lock ./
-COPY pnpm-workspace.yaml ./
ENV PUPPETEER_SKIP_DOWNLOAD=true
# Install dependencies while ignoring scripts (including Puppeteer's installation)
-RUN bun install
+RUN bun install --frozen-lockfile🤖 Prompt for AI Agents |
||
|
|
||
| # Copy the rest of the application code | ||
| COPY . . | ||
| RUN cd libs/prisma-service && npx prisma generate | ||
| RUN pnpm run build cloud-wallet | ||
| RUN pnpm prune --prod | ||
| # RUN cd libs/prisma-service && npx prisma migrate deploy && npx prisma generate | ||
| RUN cd libs/prisma-service && bunx prisma generate | ||
|
|
||
| # Build the user service | ||
| RUN bun --bun run build cloud-wallet | ||
|
|
||
| # Stage 2: Create the final image | ||
| FROM node:24-alpine3.21 | ||
| FROM oven/bun:1.3-alpine | ||
|
|
||
| RUN apk update && apk upgrade && apk add --no-cache openssl \ | ||
| && rm -rf /var/cache/apk/* \ | ||
| && addgroup -g 1001 -S nodejs \ | ||
| && adduser -S nextjs -u 1001 | ||
| # Set the working directory | ||
| WORKDIR /app | ||
| COPY --from=build /app/dist/apps/cloud-wallet/ ./dist/apps/cloud-wallet/ | ||
| COPY --from=build /app/libs/ ./libs/ | ||
| COPY --from=build /app/node_modules ./node_modules | ||
| #COPY --from=build /app/package.json ./ | ||
| COPY --from=build /app/node_modules ./node_modules | ||
|
|
||
| USER nextjs | ||
| CMD ["sh", "-c", "cd libs/prisma-service && npx prisma migrate deploy && cd ../.. && node dist/apps/cloud-wallet/main.js"] | ||
| # Set the command to run the microservice | ||
| CMD ["sh", "-c", "cd libs/prisma-service && bunx prisma migrate deploy && bunx prisma generate && cd ../.. && bun --bun dist/apps/cloud-wallet/main.js"] | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,26 +1,47 @@ | ||||||
| # Stage 1: Build the application | ||||||
| FROM node:24-alpine3.21 AS build | ||||||
| FROM oven/bun:1.3-alpine as build | ||||||
|
Check warning on line 2 in Dockerfiles/Dockerfile.connection
|
||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use uppercase SonarCloud flagged this; per Dockerfile best practices and consistency with -FROM oven/bun:1.3-alpine as build
+FROM oven/bun:1.3-alpine AS build📝 Committable suggestion
Suggested change
🧰 Tools🪛 GitHub Check: SonarCloud Code Analysis[warning] 2-2: Replace "as" with upper case format "AS". 🤖 Prompt for AI Agents |
||||||
| # Install OpenSSL | ||||||
| RUN apk update && apk upgrade && apk add --no-cache openssl \ | ||||||
| && rm -rf /var/cache/apk/* | ||||||
| RUN npm install -g pnpm@9.15.3 --ignore-scripts | ||||||
| # Set the working directory | ||||||
| WORKDIR /app | ||||||
| COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./ | ||||||
|
|
||||||
| # Copy package.json and package-lock.json | ||||||
| COPY package.json ./ | ||||||
| COPY bun.lock ./ | ||||||
| COPY pnpm-workspace.yaml ./ | ||||||
| #COPY package-lock.json ./ | ||||||
|
|
||||||
| ENV PUPPETEER_SKIP_DOWNLOAD=true | ||||||
| RUN pnpm i --frozen-lockfile --ignore-scripts | ||||||
|
|
||||||
| # Install dependencies while ignoring scripts (including Puppeteer's installation) | ||||||
| RUN bun install | ||||||
|
Comment on lines
+9
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Verify workspaces are declared in root package.json and pnpm-workspace.yaml is no longer authoritative
rg -nP '"workspaces"' package.json -C2
fd -HI -t f -d 2 '^pnpm-workspace\.yaml$'Repository: credebl/platform Length of output: 176 🏁 Script executed: # Search for references to pnpm-workspace.yaml in the codebase
rg 'pnpm-workspace' --type-list | head -5
rg 'pnpm-workspace' -g '!node_modules' -g '!.git'
# Check the Dockerfile context - look for other Dockerfiles and build configuration
fd -HI -t f -name 'Dockerfile*' | head -20
# Check if --frozen-lockfile is referenced in relation to bun in the repo
rg 'frozen-lockfile|frozen.lock' -t dockerfileRepository: credebl/platform Length of output: 2000 🏁 Script executed: # Get full content of Dockerfile.connection to understand the build context
cat Dockerfiles/Dockerfile.connection
# Check if there's any pnpm reference in Dockerfile.connection
rg 'pnpm' Dockerfiles/Dockerfile.connection
# Verify bun install --frozen-lockfile is correct syntax by checking if it's used elsewhere
rg 'frozen-lockfile'
rg 'bun install' Dockerfiles/ -A1 -B1
# Check what pnpm-workspace.yaml contains
head -30 pnpm-workspace.yamlRepository: credebl/platform Length of output: 5519 🏁 Script executed: # Verify bun install --frozen-lockfile syntax - check Bun documentation or existing usage
web_search "bun install --frozen-lockfile"
# Also check if there's a bun.lock pattern in any documentation or CI files
rg 'bun.lock' --type-list 2>/dev/null || rg 'bun.lock' -g '*.md' -g '*.yml' -g '*.yaml' -g '*.json'
# Check if there are any CI/build scripts that reference bun with frozen-lockfile
fd -HI -t f \( -name '*.yml' -o -name '*.yaml' -o -name '*.sh' \) | head -20Repository: credebl/platform Length of output: 340 🌐 Web query:
💡 Result: The syntax for using the --frozen-lockfile flag with bun install is: bun install --frozen-lockfile[1][2] This flag ensures reproducible installs by installing the exact versions of each package specified in the bun.lock lockfile. If the package.json disagrees with the lockfile (e.g., due to version range changes or other mismatches), Bun will exit with an error like "error: lockfile had changes, but lockfile is frozen" and will not update the lockfile[1][3][4]. It is particularly useful in CI/CD environments to verify that the lockfile is up-to-date and committed to version control. The bun.lock must be present and committed for this to work reliably[1]. Equivalent configuration in bunfig.toml: [install] frozenLockfile = true[1] Note: Some past bugs in monorepos or with pruned workspaces could cause false "changes" errors even when the lockfile was unchanged, but official docs confirm the intended behavior[1][3][4][5]. For lockfile-only generation with frozen check during migration: bun install --save-text-lockfile --frozen-lockfile --lockfile-only[6]. Citations:
Add Two issues in the dependency-install layer:
🔧 Proposed fix # Copy package.json and package-lock.json
COPY package.json ./
COPY bun.lock ./
-COPY pnpm-workspace.yaml ./
-#COPY package-lock.json ./
ENV PUPPETEER_SKIP_DOWNLOAD=true
# Install dependencies while ignoring scripts (including Puppeteer's installation)
-RUN bun install
+RUN bun install --frozen-lockfile🤖 Prompt for AI Agents |
||||||
|
|
||||||
| # Copy the rest of the application code | ||||||
| COPY . . | ||||||
| RUN cd libs/prisma-service && npx prisma generate | ||||||
| RUN pnpm run build connection | ||||||
| RUN pnpm prune --prod | ||||||
| # RUN cd libs/prisma-service && npx prisma migrate deploy && npx prisma generate | ||||||
| RUN cd libs/prisma-service && bunx prisma generate | ||||||
|
|
||||||
| # Build the connection service | ||||||
| RUN bun --bun run build connection | ||||||
|
|
||||||
| # Stage 2: Create the final image | ||||||
| FROM node:24-alpine3.21 | ||||||
| FROM oven/bun:1.3-alpine | ||||||
| # Install OpenSSL | ||||||
| RUN apk update && apk upgrade && apk add --no-cache openssl \ | ||||||
| && rm -rf /var/cache/apk/* \ | ||||||
| && addgroup -g 1001 -S nodejs \ | ||||||
| && adduser -S nextjs -u 1001 | ||||||
| # RUN npm install -g pnpm | ||||||
| # Set the working directory | ||||||
| WORKDIR /app | ||||||
| COPY --from=build /app/dist/apps/connection/ ./dist/apps/connection/ | ||||||
| COPY --from=build /app/libs/ ./libs/ | ||||||
| COPY --from=build /app/node_modules ./node_modules | ||||||
| #COPY --from=build /app/package.json ./ | ||||||
| COPY --from=build /app/node_modules ./node_modules | ||||||
|
|
||||||
| # Install production dependencies for the final image | ||||||
| #RUN npm i --only=production | ||||||
| USER nextjs | ||||||
| CMD ["sh", "-c", "cd libs/prisma-service && npx prisma migrate deploy && cd ../.. && node dist/apps/connection/main.js"] | ||||||
| # Set the command to run the microservice | ||||||
| CMD ["sh", "-c", "cd libs/prisma-service && bunx prisma migrate deploy && bunx prisma generate && cd ../.. && bun --bun dist/apps/connection/main.js"] | ||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,26 +1,47 @@ | ||||||||||||||||||||||||||||||||||||||||
| # Stage 1: Build the application | ||||||||||||||||||||||||||||||||||||||||
| FROM node:24-alpine3.21 AS build | ||||||||||||||||||||||||||||||||||||||||
| FROM oven/bun:1.3-alpine as build | ||||||||||||||||||||||||||||||||||||||||
|
Check warning on line 2 in Dockerfiles/Dockerfile.geolocation
|
||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use uppercase -FROM oven/bun:1.3-alpine as build
+FROM oven/bun:1.3-alpine AS build📝 Committable suggestion
Suggested change
🧰 Tools🪛 GitHub Check: SonarCloud Code Analysis[warning] 2-2: Replace "as" with upper case format "AS". 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||
| # Install OpenSSL | ||||||||||||||||||||||||||||||||||||||||
| RUN apk update && apk upgrade && apk add --no-cache openssl \ | ||||||||||||||||||||||||||||||||||||||||
| && rm -rf /var/cache/apk/* | ||||||||||||||||||||||||||||||||||||||||
| RUN npm install -g pnpm@9.15.3 --ignore-scripts | ||||||||||||||||||||||||||||||||||||||||
| # Set the working directory | ||||||||||||||||||||||||||||||||||||||||
| WORKDIR /app | ||||||||||||||||||||||||||||||||||||||||
| COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./ | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| # Copy package.json and package-lock.json | ||||||||||||||||||||||||||||||||||||||||
| COPY package.json ./ | ||||||||||||||||||||||||||||||||||||||||
| COPY bun.lock ./ | ||||||||||||||||||||||||||||||||||||||||
| COPY pnpm-workspace.yaml ./ | ||||||||||||||||||||||||||||||||||||||||
| #COPY package-lock.json ./ | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| ENV PUPPETEER_SKIP_DOWNLOAD=true | ||||||||||||||||||||||||||||||||||||||||
| RUN pnpm i --frozen-lockfile --ignore-scripts | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| # Install dependencies while ignoring scripts (including Puppeteer's installation) | ||||||||||||||||||||||||||||||||||||||||
| RUN bun install | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+9
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use Same as the other service Dockerfiles in this PR. Pin the install to the lockfile and remove the now-redundant 🔧 Proposed fix # Copy package.json and package-lock.json
COPY package.json ./
COPY bun.lock ./
-COPY pnpm-workspace.yaml ./
-#COPY package-lock.json ./
ENV PUPPETEER_SKIP_DOWNLOAD=true
# Install dependencies while ignoring scripts (including Puppeteer's installation)
-RUN bun install
+RUN bun install --frozen-lockfile📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| # Copy the rest of the application code | ||||||||||||||||||||||||||||||||||||||||
| COPY . . | ||||||||||||||||||||||||||||||||||||||||
| RUN cd libs/prisma-service && npx prisma generate | ||||||||||||||||||||||||||||||||||||||||
| RUN pnpm run build geo-location | ||||||||||||||||||||||||||||||||||||||||
| RUN pnpm prune --prod | ||||||||||||||||||||||||||||||||||||||||
| # RUN cd libs/prisma-service && npx prisma migrate deploy && npx prisma generate | ||||||||||||||||||||||||||||||||||||||||
| RUN cd libs/prisma-service && bunx prisma generate | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| # Build the geo-location service | ||||||||||||||||||||||||||||||||||||||||
| RUN bun --bun run build geo-location | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| # Stage 2: Create the final image | ||||||||||||||||||||||||||||||||||||||||
| FROM node:24-alpine3.21 | ||||||||||||||||||||||||||||||||||||||||
| FROM oven/bun:1.3-alpine | ||||||||||||||||||||||||||||||||||||||||
| # Install OpenSSL | ||||||||||||||||||||||||||||||||||||||||
| RUN apk update && apk upgrade && apk add --no-cache openssl \ | ||||||||||||||||||||||||||||||||||||||||
| && rm -rf /var/cache/apk/* \ | ||||||||||||||||||||||||||||||||||||||||
| && addgroup -g 1001 -S nodejs \ | ||||||||||||||||||||||||||||||||||||||||
| && adduser -S nextjs -u 1001 | ||||||||||||||||||||||||||||||||||||||||
| # RUN npm install -g pnpm | ||||||||||||||||||||||||||||||||||||||||
| # Set the working directory | ||||||||||||||||||||||||||||||||||||||||
| WORKDIR /app | ||||||||||||||||||||||||||||||||||||||||
| COPY --from=build /app/dist/apps/geo-location/ ./dist/apps/geo-location/ | ||||||||||||||||||||||||||||||||||||||||
| COPY --from=build /app/libs/ ./libs/ | ||||||||||||||||||||||||||||||||||||||||
| COPY --from=build /app/node_modules ./node_modules | ||||||||||||||||||||||||||||||||||||||||
| #COPY --from=build /app/package.json ./ | ||||||||||||||||||||||||||||||||||||||||
| COPY --from=build /app/node_modules ./node_modules | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| # Install production dependencies for the final image | ||||||||||||||||||||||||||||||||||||||||
| #RUN npm i --only=production | ||||||||||||||||||||||||||||||||||||||||
| USER nextjs | ||||||||||||||||||||||||||||||||||||||||
| CMD ["sh", "-c", "cd libs/prisma-service && npx prisma migrate deploy && cd ../.. && node dist/apps/geo-location/main.js"] | ||||||||||||||||||||||||||||||||||||||||
| # Set the command to run the microservice | ||||||||||||||||||||||||||||||||||||||||
| CMD ["sh", "-c", "cd libs/prisma-service && bunx prisma migrate deploy && bunx prisma generate && cd ../.. && bun --bun dist/apps/geo-location/main.js"] | ||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
Remove redundant
apkcommands.Lines 4-5 are redundant since lines 6-12 perform another
apk update && apk upgradeand also installopenssl. This creates unnecessary image layers and duplicates the openssl installation.🔎 Apply this diff to consolidate:
🤖 Prompt for AI Agents