Fix build: externalize elysia packages, use standalone output, fix NODE_ENV
- Add serverExternalPackages for @elysiajs/static and elysia to prevent webpack from bundling dynamic imports that cause Html prerender error - Use output: standalone for proper Docker deployment - Comment out NODE_ENV=development in .env.example to avoid conflict with next build which requires NODE_ENV=production - Set NODE_ENV=production before build step in Dockerfile - Update runtime stage to use standalone output structure Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -33,4 +33,4 @@ SESSION_PASSWORD="your_session_password_min_32_characters_long_secure"
|
|||||||
ELEVENLABS_API_KEY=your_elevenlabs_api_key
|
ELEVENLABS_API_KEY=your_elevenlabs_api_key
|
||||||
|
|
||||||
# Environment (optional, defaults to development)
|
# Environment (optional, defaults to development)
|
||||||
NODE_ENV=development
|
# NODE_ENV=development
|
||||||
|
|||||||
12
Dockerfile
12
Dockerfile
@@ -27,6 +27,7 @@ RUN cp .env.example .env
|
|||||||
RUN bun x prisma generate
|
RUN bun x prisma generate
|
||||||
|
|
||||||
# Build the application frontend
|
# Build the application frontend
|
||||||
|
ENV NODE_ENV=production
|
||||||
RUN bun run build
|
RUN bun run build
|
||||||
|
|
||||||
# Stage 2: Runtime
|
# Stage 2: Runtime
|
||||||
@@ -43,17 +44,14 @@ RUN apt-get update && apt-get install -y \
|
|||||||
# Set the working directory
|
# Set the working directory
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy necessary files from build stage
|
# Copy necessary files from build stage (standalone output)
|
||||||
COPY --from=build /app/package.json ./
|
COPY --from=build /app/.next/standalone ./
|
||||||
COPY --from=build /app/tsconfig.json ./
|
COPY --from=build /app/.next/static ./.next/static
|
||||||
COPY --from=build /app/.next ./.next
|
|
||||||
COPY --from=build /app/public ./public
|
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
|
COPY --from=build /app/prisma ./prisma
|
||||||
|
|
||||||
# Expose the port
|
# Expose the port
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|
||||||
# Start the application
|
# Start the application
|
||||||
CMD ["bun", "start"]
|
CMD ["bun", "server.js"]
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import type { NextConfig } from "next";
|
import type { NextConfig } from "next";
|
||||||
|
|
||||||
const nextConfig: NextConfig = {
|
const nextConfig: NextConfig = {
|
||||||
|
output: 'standalone',
|
||||||
|
serverExternalPackages: ['@elysiajs/static', 'elysia'],
|
||||||
experimental: {},
|
experimental: {},
|
||||||
allowedDevOrigins: [
|
allowedDevOrigins: [
|
||||||
"http://192.168.1.82:3000", // buat akses dari HP/device lain
|
"http://192.168.1.82:3000", // buat akses dari HP/device lain
|
||||||
|
|||||||
Reference in New Issue
Block a user