Initial commit: deardiary project setup
This commit is contained in:
39
backend/Dockerfile
Normal file
39
backend/Dockerfile
Normal file
@@ -0,0 +1,39 @@
|
||||
# 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"]
|
||||
Reference in New Issue
Block a user