FIx Docker File

This commit is contained in:
2026-03-10 10:56:15 +08:00
parent dc13e37a02
commit 8b22d01e0d
2 changed files with 60 additions and 48 deletions

19
.env Normal file
View File

@@ -0,0 +1,19 @@
DATABASE_URL="postgresql://bip:Production_123@localhost:5433/desa-darmasaba-v0.0.1?schema=public"
# Seafile
SEAFILE_TOKEN=20a19f4a04032215d50ce53292e6abdd38b9f806
SEAFILE_REPO_ID=f0e9ee4a-fd13-49a2-81c0-f253951d063a
SEAFILE_URL=https://cld-dkr-makuro-seafile.wibudev.com
SEAFILE_PUBLIC_SHARE_TOKEN=3a9a9ecb5e244f4da8ae
# Upload
WIBU_UPLOAD_DIR=uploads
WIBU_DOWNLOAD_DIR="./download"
NEXT_PUBLIC_BASE_URL="http://localhost:3000"
EMAIL_USER=nicoarya20@gmail.com
EMAIL_PASS=hymmfpcaqzqkfgbh
BASE_SESSION_KEY=kp9sGx91as0Kj2Ls81nAsl2Kdj13KsxP
BASE_TOKEN_KEY=Qm82JsA92lMnKw0291mxKaaP02KjslaA
# BOT-TELE
BOT_TOKEN=8498428675:AAEQwAUjTqpvgyyC5C123nP1mAxhOg12Ph0
CHAT_ID=5251328671

View File

@@ -1,69 +1,62 @@
# ============================== # Stage 1: Build
# Stage 1: Builder (Debian) FROM oven/bun:1.3 AS build
# ==============================
FROM node:20-bookworm-slim AS builder
WORKDIR /app # Install build dependencies for native modules
RUN apt-get update && apt-get install -y \
# Install dependencies yang sebelumnya pakai apk python3 \
RUN apt-get update && apt-get install -y --no-install-recommends \ make \
libc6 \ g++ \
git \
openssl \
ca-certificates \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
COPY package.json bun.lockb* ./ # Set the working directory
WORKDIR /app
ENV ONNXRUNTIME_NODE_INSTALL_CUDA=0 # Copy package files
ENV SHARP_IGNORE_GLOBAL_LIBVIPS=1 COPY package.json bun.lock* ./
RUN npm install --ignore-scripts # Install dependencies
RUN bun install --frozen-lockfile
# Copy the rest of the application code
COPY . . COPY . .
# Skip telemetry & limit memory # Use .env.example as default env for build
ENV NEXT_TELEMETRY_DISABLED=1 RUN cp .env.example .env
ENV NODE_OPTIONS="--max-old-space-size=4096"
# Generate prisma client # Generate Prisma client
RUN npx prisma generate RUN bun x prisma generate
# Build Next.js # Generate API types
RUN npm run build RUN bun run gen:api
# Build the application frontend
RUN bun run build
# ============================== # Stage 2: Runtime
# Stage 2: Runner (Debian) FROM oven/bun:1.3-slim AS runtime
# ==============================
FROM node:20-bookworm-slim AS runner
WORKDIR /app
# Set environment variables
ENV NODE_ENV=production ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
RUN apt-get update && apt-get install -y --no-install-recommends \ # Install runtime dependencies
openssl \ RUN apt-get update && apt-get install -y \
ca-certificates \ postgresql-client \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
# Buat user non-root (cara Debian) # Set the working directory
RUN groupadd --system --gid 1001 nodejs \ WORKDIR /app
&& useradd --system --uid 1001 --gid nodejs nextjs
COPY --from=builder /app/public ./public # Copy necessary files from build stage
COPY --from=builder /app/.next ./.next COPY --from=build /app/package.json ./
COPY --from=builder /app/node_modules ./node_modules COPY --from=build /app/tsconfig.json ./
COPY --from=builder /app/package.json ./package.json COPY --from=build /app/dist ./dist
COPY --from=build /app/generated ./generated
RUN chown -R nextjs:nodejs /app COPY --from=build /app/src ./src
COPY --from=build /app/node_modules ./node_modules
USER nextjs COPY --from=build /app/prisma ./prisma
# Expose the port
EXPOSE 3000 EXPOSE 3000
ENV PORT=3000 # Start the application
ENV HOSTNAME="0.0.0.0" CMD ["bun", "start"]
CMD ["npx", "next", "start"]