Install sharp dependencies for Linux

This commit is contained in:
Parsa Nazer
2025-11-10 13:25:54 +03:30
parent 99ccf46698
commit 75e7c64aab
+15 -4
View File
@@ -1,20 +1,31 @@
FROM oven/bun:1 AS build-stage FROM oven/bun:1 AS build-stage
WORKDIR /app WORKDIR /app
# Limit memory for Node processes (3 GB) # Install sharp dependencies for Linux
RUN apt-get update && apt-get install -y \
python3 \
make \
g++ \
&& rm -rf /var/lib/apt/lists/*
COPY package.json bun.lockb* ./ COPY package.json bun.lockb* ./
RUN bun install --frozen-lockfile RUN bun install --frozen-lockfile
# --- ✅ Rebuild sharp for correct Linux architecture ---
RUN bun x npm rebuild sharp --platform=linux --arch=x64 --target=$(node -v | sed 's/v//')
COPY . . COPY . .
RUN bun run build RUN bun run build
FROM oven/bun:1 AS production-stage FROM oven/bun:1 AS production-stage
WORKDIR /app WORKDIR /app
# Install sharp dependencies in production stage as well
RUN apt-get update && apt-get install -y \
python3 \
make \
g++ \
&& rm -rf /var/lib/apt/lists/*
COPY --from=build-stage /app /app COPY --from=build-stage /app /app
EXPOSE 3000 EXPOSE 3000
ENV NODE_ENV=production ENV NODE_ENV=production
CMD ["bun", "run", "start"] CMD ["bun", "run", "start"]