Files
butcem/Dockerfile
T
suphicakir c52e8f9976 build(deps): SheetJS 0.20.3 resmi dağıtımdan vendor/ altına eklendi
npm 11 uzak tarball'ı indirmediği için paket depoya alındı
(sha256 8dc73fc3b00203e72d176e85b50938627c7b086e607c682e8d3c22c02bb99fe8);
Dockerfile deps aşaması vendor/ klasörünü kopyalar.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 09:31:37 +03:00

62 lines
2.3 KiB
Docker
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# syntax=docker/dockerfile:1
# BÜTÇEM — çok aşamalı üretim imajı (Next.js standalone çıktı).
# Build: docker build --build-arg APP_COMMIT=$(git rev-parse --short HEAD) -t butcem .
# Çalıştır: docker run -p 3000:3000 --env-file .env.production -v butcem-uploads:/app/uploads butcem
# Başlarken: replica set kontrolü, bekleyen migration'lar, ilk admin (docker-entrypoint.sh).
ARG NODE_VERSION=26
# 1) Bağımlılıklar — yalnızca lock dosyası değişince yeniden çalışır.
FROM node:${NODE_VERSION}-alpine AS deps
WORKDIR /app
RUN apk add --no-cache libc6-compat
COPY package.json package-lock.json ./
# SheetJS resmi dağıtımdan vendor/ altında (npm uzak tarball indirmez).
COPY vendor ./vendor
RUN npm ci --no-audit --no-fund
# 2) Build
FROM node:${NODE_VERSION}-alpine AS builder
WORKDIR /app
ARG APP_VERSION=""
ARG APP_COMMIT="unknown"
ENV NEXT_TELEMETRY_DISABLED=1 \
APP_VERSION=${APP_VERSION} \
APP_COMMIT=${APP_COMMIT}
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# Uygulama + başlatma betiği (migration ve ilk admin; tek dosya, tsx gerekmez).
RUN npm run build && npm run build:scripts
# 3) Çalışma zamanı — yalnızca standalone çıktı, root olmayan kullanıcı.
FROM node:${NODE_VERSION}-alpine AS runner
WORKDIR /app
ARG APP_VERSION=""
ARG APP_COMMIT="unknown"
ENV NODE_ENV=production \
NEXT_TELEMETRY_DISABLED=1 \
PORT=3000 \
HOSTNAME=0.0.0.0 \
UPLOAD_DIR=/app/uploads \
APP_VERSION=${APP_VERSION} \
APP_COMMIT=${APP_COMMIT}
RUN addgroup -S -g 1001 nodejs && adduser -S -u 1001 -G nodejs nextjs \
&& mkdir -p /app/uploads && chown nextjs:nodejs /app/uploads
COPY --from=builder --chown=nextjs:nodejs /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
COPY --from=builder --chown=nextjs:nodejs /app/dist/bootstrap.mjs ./scripts/bootstrap.mjs
COPY --chown=nextjs:nodejs --chmod=755 docker-entrypoint.sh ./docker-entrypoint.sh
USER nextjs
VOLUME ["/app/uploads"]
EXPOSE 3000
# start-period: ilk deploy'da migration'lar için pay.
HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \
CMD node -e "fetch('http://127.0.0.1:'+(process.env.PORT||3000)+'/api/health').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"
ENTRYPOINT ["/app/docker-entrypoint.sh"]