Skip to content

Commit 7b9ff6d

Browse files
committed
refactor(api): update Dockerfile to include sharp as an external dependency
1 parent fe07285 commit 7b9ff6d

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

apps/api/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,28 @@ RUN DATABASE_URL="postgresql://build:build@localhost:5432/build" bun run db:gene
2020
# tsc first: --compile drops emitDecoratorMetadata (needed by tsyringe) when fed TS.
2121
RUN ./node_modules/.bin/tsc
2222
RUN cp -r src/generated dist/apps/api/src/generated
23+
24+
# sharp is a native addon — bun --compile can't embed its .node binaries, so keep
25+
# it external and ship only its dependency closure (built for musl) at runtime.
2326
RUN bun build --compile --minify-whitespace --minify-syntax \
2427
--define 'process.env.NODE_ENV="production"' \
28+
--external sharp \
2529
--target bun-linux-x64 \
2630
--outfile /app/server \
2731
dist/apps/api/src/app.js
2832

33+
RUN mkdir -p /native && cd /native \
34+
&& echo '{"name":"native","version":"0.0.0"}' > package.json \
35+
&& bun add sharp@^0.34.5
36+
2937
FROM alpine:latest AS runner
3038
WORKDIR /app/apps/api
3139

3240
RUN apk add --no-cache openssl curl libstdc++ libgcc
3341

3442
COPY --from=build /app/server ./server
3543
COPY --from=build /app/apps/api/prisma ./prisma
44+
COPY --from=build /native/node_modules ./node_modules
3645

3746
RUN mkdir -p uploads
3847

0 commit comments

Comments
 (0)