Feat: added docker

This commit is contained in:
2025-01-22 12:36:05 +03:00
parent ac4f0b0be8
commit eb21d5f73d
9 changed files with 111 additions and 151 deletions

50
Dockerfile Normal file
View File

@@ -0,0 +1,50 @@
FROM oven/bun:1-alpine AS base
FROM base AS deps
RUN apk update && apk upgrade && apk add --no-cache libc6-compat
WORKDIR /app
COPY package.json bun.lockb ./
RUN \
if [ -f bun.lockb ]; then bun i --frozen-lockfile; \
else echo "Lockfile not found." && exit 1; \
fi
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
ENV NEXT_TELEMETRY_DISABLED=1
RUN \
if [ -f bun.lockb ]; then bun run build; \
else echo "Lockfile not found." && exit 1; \
fi
FROM base AS runner
WORKDIR /app
RUN apk update && apk upgrade && apk add --no-cache dumb-init
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
COPY --from=builder /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
USER nextjs
EXPOSE 3000
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
CMD ["dumb-init", "bun", "run", "server.js"]