Skip to content

Commit d151deb

Browse files
committed
chore(api): update Dockerfile to install production dependencies inside image
1 parent 69bf8b6 commit d151deb

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

apps/api/Dockerfile

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,29 @@
11
# Use Node.js runtime for production
22
FROM node:20-alpine
33

4-
# Install wget for health check
5-
RUN apk add --no-cache wget
4+
# Install required packages (wget for healthcheck, curl/bash for bun install, libc compat for prisma)
5+
RUN apk add --no-cache wget curl bash libc6-compat openssl
66

77
WORKDIR /app
88

9-
# Copy the entire pre-built bundle (no dependencies needed)
9+
# Copy manifests first and install production deps inside the image (avoid broken bun symlinks)
10+
COPY package.json bun.lock ./
11+
12+
# Install bun and deps
13+
RUN curl -fsSL https://bun.sh/install | bash \
14+
&& export PATH="/root/.bun/bin:$PATH" \
15+
&& bun install --production --frozen-lockfile --ignore-scripts
16+
17+
# Now copy the pre-built app contents (dist/, prisma/, etc.)
1018
COPY . .
1119

1220
# Set environment variables
1321
ENV NODE_ENV=production
1422
ENV PORT=3333
1523

1624
# Create a non-root user for security
17-
RUN addgroup --system nestjs && adduser --system --ingroup nestjs nestjs
18-
19-
# Change ownership to nestjs user
20-
RUN chown -R nestjs:nestjs /app
25+
RUN addgroup --system nestjs && adduser --system --ingroup nestjs nestjs \
26+
&& chown -R nestjs:nestjs /app
2127

2228
USER nestjs
2329

apps/api/buildspec.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ phases:
6666
- '[ -f "../docker-build/src/main.js" ] || { echo "❌ main.js not found in docker-build/src"; exit 1; }'
6767

6868
# Copy entire node_modules for runtime (includes @trycompai/db from npm)
69-
- echo "Bundling all runtime dependencies..."
70-
- cp -r ../../node_modules ../docker-build/
69+
- echo "Skipping host node_modules copy; Dockerfile installs prod deps inside image"
7170

7271
# Copy Dockerfile
7372
- echo "Copying Dockerfile..."

0 commit comments

Comments
 (0)