diff --git a/.env b/.env deleted file mode 100644 index f701c913..00000000 --- a/.env +++ /dev/null @@ -1,19 +0,0 @@ -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=8479423145:AAE9ArrOgTD3DyVxYSVs3IXN40u_sL6c9sw -CHAT_ID=-1003368982298 \ No newline at end of file diff --git a/.gitignore b/.gitignore index dbfeaa89..6223a08f 100644 --- a/.gitignore +++ b/.gitignore @@ -30,10 +30,7 @@ yarn-error.log* # env # env local files (keep .env.example) -.env.local -.env*.local -.env.production -.env.development +.env* !.env.example # QC diff --git a/Dockerfile b/Dockerfile index 3e198698..4d7a6742 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,61 +1,68 @@ -# Stage 1: Build -FROM oven/bun:1.3 AS build +# ============================== +# Stage 1: Builder +# ============================== +FROM oven/bun:1-debian AS builder -# Install build dependencies for native modules -RUN apt-get update && apt-get install -y \ - python3 \ - make \ - g++ \ - && rm -rf /var/lib/apt/lists/* - -# Set the working directory WORKDIR /app -# Copy package files -COPY package.json bun.lock* ./ +RUN apt-get update && apt-get install -y --no-install-recommends \ + libc6 \ + git \ + openssl \ + ca-certificates \ + && rm -rf /var/lib/apt/lists/* -# Install dependencies -# RUN bun install --frozen-lockfile -RUN bun install --no-save +COPY package.json bun.lockb* ./ -# Copy the rest of the application code +ENV SHARP_IGNORE_GLOBAL_LIBVIPS=1 +ENV NEXT_TELEMETRY_DISABLED=1 +ENV NODE_OPTIONS="--max-old-space-size=4096" + +RUN bun install --frozen-lockfile COPY . . -# Use .env.example as default env for build -RUN cp .env.example .env +RUN cp .env.example .env || true -# Generate Prisma client -RUN bun x prisma generate +ENV PRISMA_CLI_BINARY_TARGETS=debian-openssl-3.0.x +RUN bunx prisma generate -# Build the application frontend -ENV NODE_ENV=production RUN bun run build -# Stage 2: Runtime -FROM oven/bun:1.3-slim AS runtime +# ============================== +# Stage 2: Runner (Production) +# ============================== +FROM oven/bun:1-debian AS runner -# Set environment variables -ENV NODE_ENV=production - -# Install runtime dependencies -RUN apt-get update && apt-get install -y \ - postgresql-client \ - && rm -rf /var/lib/apt/lists/* - -# Set the working directory WORKDIR /app -# Copy necessary files from build stage -COPY --from=build /app/package.json ./ -COPY --from=build /app/tsconfig.json ./ -COPY --from=build /app/.next ./.next -COPY --from=build /app/public ./public -COPY --from=build /app/src ./src -COPY --from=build /app/node_modules ./node_modules -COPY --from=build /app/prisma ./prisma +ENV NODE_ENV=production +ENV NEXT_TELEMETRY_DISABLED=1 +ENV PRISMA_CLI_BINARY_TARGETS=debian-openssl-3.0.x + +RUN apt-get update && apt-get install -y --no-install-recommends \ + openssl \ + ca-certificates \ + && rm -rf /var/lib/apt/lists/* + +RUN groupadd --system --gid 1001 nodejs \ + && useradd --system --uid 1001 --gid nodejs nextjs + +COPY --from=builder /app/node_modules ./node_modules +COPY --from=builder /app/.next ./.next +COPY --from=builder /app/public ./public +COPY --from=builder /app/package.json ./package.json +COPY --from=builder /app/prisma ./prisma +COPY --from=builder /app/src ./src +COPY --from=builder /app/next.config.js ./next.config.js +COPY --from=builder /app/tsconfig.json ./tsconfig.json + +RUN chown -R nextjs:nodejs /app + +USER nextjs -# Expose the port EXPOSE 3000 -# Start the application +ENV PORT=3000 +ENV HOSTNAME="0.0.0.0" + CMD ["bun", "start"] \ No newline at end of file diff --git a/package.json b/package.json index a6d06d6d..ec99bfde 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,8 @@ "start": "next start", "test:api": "vitest run", "test:e2e": "playwright test", - "test": "bun run test:api && bun run test:e2e" + "test": "bun run test:api && bun run test:e2e", + "gen:api": "" }, "prisma": { "seed": "bun run prisma/seed.ts"