Merge branch 'main' into stg
This commit is contained in:
47
.dockerignore
Normal file
47
.dockerignore
Normal file
@@ -0,0 +1,47 @@
|
||||
node_modules
|
||||
.next
|
||||
.git
|
||||
.env
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
bun-debug.log*
|
||||
|
||||
# Docker files
|
||||
Dockerfile
|
||||
.dockerignore
|
||||
|
||||
# OS files
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# Markdown/Documentation
|
||||
README.md
|
||||
GEMINI.md
|
||||
AGENTS.md
|
||||
AUDIT_REPORT.md
|
||||
QWEN.md
|
||||
NOTE.md
|
||||
task-project-apbdes.md
|
||||
MUSIK_CREATE_ANALYSIS.md
|
||||
darkMode.md
|
||||
/test-results
|
||||
/playwright-report
|
||||
/tmp_assets
|
||||
/foldergambar
|
||||
/googleapi
|
||||
/xx
|
||||
/xx.ts
|
||||
/xx.txt
|
||||
/test.txt
|
||||
/x.json
|
||||
/x.sh
|
||||
/xcoba.ts
|
||||
/xcoba2.ts
|
||||
/gambar.ttx
|
||||
/test-berita-state.ts
|
||||
82
Dockerfile
82
Dockerfile
@@ -1,3 +1,77 @@
|
||||
# # Stage 1: Build
|
||||
# FROM oven/bun:1.1 AS build
|
||||
|
||||
# # 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
|
||||
|
||||
# # Disable telemetry and set build-time environment
|
||||
# ENV NEXT_TELEMETRY_DISABLED=1
|
||||
# ENV NODE_ENV=production
|
||||
# ENV NODE_OPTIONS="--max-old-space-size=4096"
|
||||
# # Critical ENV for API route evaluation during build
|
||||
# ENV WIBU_UPLOAD_DIR=uploads
|
||||
# ENV DATABASE_URL="postgresql://bip:Production_123@pgbouncer:5432/desa-darmasaba-staging?pgbouncer=true"
|
||||
|
||||
# # Copy package files
|
||||
# COPY package.json bun.lock* ./
|
||||
|
||||
# # Install dependencies with frozen lockfile
|
||||
# RUN bun install --frozen-lockfile
|
||||
|
||||
# # Copy the rest of the application code
|
||||
# COPY . .
|
||||
|
||||
# # Use .env.example as default env for build
|
||||
# RUN cp .env.example .env
|
||||
|
||||
# # Generate Prisma client
|
||||
# RUN bun x prisma generate
|
||||
|
||||
# # Build the application frontend
|
||||
# RUN bun run build
|
||||
|
||||
# # Stage 2: Runtime
|
||||
# FROM oven/bun:1.1-slim AS runtime
|
||||
|
||||
# # Set environment variables
|
||||
# ENV NODE_ENV=production
|
||||
# ENV NEXT_TELEMETRY_DISABLED=1
|
||||
# # Ensure runtime also has critical envs if they are checked at startup
|
||||
# ENV WIBU_UPLOAD_DIR=uploads
|
||||
|
||||
# # 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/bun.lock* ./
|
||||
# COPY --from=build /app/next.config.ts ./
|
||||
# COPY --from=build /app/postcss.config.cjs ./
|
||||
# COPY --from=build /app/tsconfig.json ./
|
||||
# COPY --from=build /app/.next ./.next
|
||||
# COPY --from=build /app/public ./public
|
||||
# COPY --from=build /app/node_modules ./node_modules
|
||||
# COPY --from=build /app/prisma ./prisma
|
||||
|
||||
# # Expose the port
|
||||
# EXPOSE 3000
|
||||
|
||||
# # Start the application
|
||||
# CMD ["bun", "start"]
|
||||
|
||||
|
||||
# Stage 1: Build
|
||||
FROM oven/bun:1.3 AS build
|
||||
|
||||
@@ -26,8 +100,10 @@ RUN cp .env.example .env
|
||||
# Generate Prisma client
|
||||
RUN bun x prisma generate
|
||||
|
||||
# Generate API types
|
||||
RUN bun run gen:api
|
||||
|
||||
# Build the application frontend
|
||||
ENV NODE_ENV=production
|
||||
RUN bun run build
|
||||
|
||||
# Stage 2: Runtime
|
||||
@@ -47,8 +123,8 @@ 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/dist ./dist
|
||||
COPY --from=build /app/generated ./generated
|
||||
COPY --from=build /app/src ./src
|
||||
COPY --from=build /app/node_modules ./node_modules
|
||||
COPY --from=build /app/prisma ./prisma
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
import type { NextConfig } from "next";
|
||||
|
||||
const nextConfig: NextConfig = {
|
||||
eslint: {
|
||||
ignoreDuringBuilds: true,
|
||||
},
|
||||
typescript: {
|
||||
ignoreBuildErrors: true,
|
||||
},
|
||||
serverExternalPackages: ['@elysiajs/static', 'elysia'],
|
||||
experimental: {},
|
||||
allowedDevOrigins: [
|
||||
|
||||
@@ -120,7 +120,7 @@
|
||||
"@types/react-dom": "^19",
|
||||
"@vitest/ui": "^4.0.18",
|
||||
"eslint": "^9",
|
||||
"eslint-config-next": "15.1.6",
|
||||
"eslint-config-next": "15.5.12",
|
||||
"jsdom": "^28.0.0",
|
||||
"msw": "^2.12.9",
|
||||
"parcel": "^2.6.2",
|
||||
|
||||
@@ -6,13 +6,6 @@ import { sendCodeOtp } from "../_lib/sendCodeOtp";
|
||||
import { cookies } from "next/headers";
|
||||
|
||||
export async function POST(req: Request) {
|
||||
if (req.method !== "POST") {
|
||||
return NextResponse.json(
|
||||
{ success: false, message: "Method Not Allowed" },
|
||||
{ status: 405 }
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
const { nomor } = await req.json();
|
||||
|
||||
@@ -43,18 +36,26 @@ export async function POST(req: Request) {
|
||||
});
|
||||
|
||||
if (!waResponse.ok) {
|
||||
console.error(`⚠️ WA Service HTTP Error: ${waResponse.status} ${waResponse.statusText}. Continuing since OTP is logged.`);
|
||||
console.error(
|
||||
`⚠️ WA Service HTTP Error: ${waResponse.status} ${waResponse.statusText}. Continuing since OTP is logged.`
|
||||
);
|
||||
console.log(`💡 Use this OTP to login: ${codeOtp}`);
|
||||
} else {
|
||||
const sendWa = await waResponse.json();
|
||||
console.log("📱 WA Response:", sendWa);
|
||||
|
||||
if (sendWa.status !== "success") {
|
||||
console.error("⚠️ WA Service Logic Error:", sendWa);
|
||||
}
|
||||
}
|
||||
} catch (waError: unknown) {
|
||||
const errorMessage = waError instanceof Error ? waError.message : String(waError);
|
||||
console.error("⚠️ WA Connection Exception. Continuing since OTP is logged.", errorMessage);
|
||||
const errorMessage =
|
||||
waError instanceof Error ? waError.message : String(waError);
|
||||
|
||||
console.error(
|
||||
"⚠️ WA Connection Exception. Continuing since OTP is logged.",
|
||||
errorMessage
|
||||
);
|
||||
}
|
||||
|
||||
const createOtpId = await prisma.kodeOtp.create({
|
||||
@@ -62,12 +63,12 @@ export async function POST(req: Request) {
|
||||
});
|
||||
|
||||
const cookieStore = await cookies();
|
||||
cookieStore.set('auth_flow', 'login', {
|
||||
cookieStore.set("auth_flow", "login", {
|
||||
httpOnly: true,
|
||||
secure: process.env.NODE_ENV === 'production',
|
||||
sameSite: 'lax',
|
||||
maxAge: 60 * 5, // 5 menit
|
||||
path: '/'
|
||||
secure: process.env.NODE_ENV === "production",
|
||||
sameSite: "lax",
|
||||
maxAge: 60 * 5,
|
||||
path: "/",
|
||||
});
|
||||
|
||||
return NextResponse.json({
|
||||
@@ -85,6 +86,7 @@ export async function POST(req: Request) {
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("❌ Error Login:", error);
|
||||
|
||||
return NextResponse.json(
|
||||
{ success: false, message: "Terjadi kesalahan saat login" },
|
||||
{ status: 500 }
|
||||
|
||||
@@ -29,16 +29,18 @@ process.on('unhandledRejection', async (error) => {
|
||||
});
|
||||
|
||||
// Handle graceful shutdown
|
||||
process.on('SIGINT', async () => {
|
||||
console.log('Received SIGINT signal. Closing database connections...');
|
||||
await prisma.$disconnect();
|
||||
process.exit(0);
|
||||
});
|
||||
if (process.env.NODE_ENV === 'production' && !process.env.NEXT_PHASE) {
|
||||
process.on('SIGINT', async () => {
|
||||
console.log('Received SIGINT signal. Closing database connections...');
|
||||
await prisma.$disconnect();
|
||||
// Allow natural exit
|
||||
});
|
||||
|
||||
process.on('SIGTERM', async () => {
|
||||
console.log('Received SIGTERM signal. Closing database connections...');
|
||||
await prisma.$disconnect();
|
||||
process.exit(0);
|
||||
});
|
||||
process.on('SIGTERM', async () => {
|
||||
console.log('Received SIGTERM signal. Closing database connections...');
|
||||
await prisma.$disconnect();
|
||||
// Allow natural exit
|
||||
});
|
||||
}
|
||||
|
||||
export default prisma;
|
||||
Reference in New Issue
Block a user