Files
deardiary/backend/Dockerfile
2026-03-26 19:57:20 +00:00

40 lines
797 B
Docker

# Build stage
FROM oven/bun:1.1-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN bun install
COPY prisma ./prisma
RUN bunx prisma generate
COPY src ./src
RUN bun build src/index.ts --outdir ./dist --target bun
# Production stage
FROM oven/bun:1.1-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
RUN addgroup --system --gid 1001 nodejs && \
adduser --system --uid 1001 bun
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./
RUN mkdir -p /data && chown -R bun:nodejs /data
USER bun
EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:3000/health || exit 1
CMD ["bun", "run", "src/index.ts"]