39 lines
1.1 KiB
Docker
39 lines
1.1 KiB
Docker
FROM node:20-alpine
|
|
|
|
# Install libc6-compat for compatibility with native node modules
|
|
RUN apk add --no-cache libc6-compat
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy dependency files first (better layer caching - reinstall only when package.json changes)
|
|
COPY sistem-km-next/package*.json ./
|
|
|
|
# Install all dependencies
|
|
RUN npm install
|
|
|
|
# Copy the rest of the application source files
|
|
COPY sistem-km-next/ .
|
|
|
|
# --- Build-time environment variables ---
|
|
# Next.js bakes NEXT_PUBLIC_* variables into the client-side JavaScript bundle
|
|
# at BUILD TIME (not runtime), so they must be available here as ENV vars.
|
|
# Coolify automatically injects these as Docker build args from the environment section.
|
|
ARG NEXT_PUBLIC_SUPABASE_URL
|
|
ARG NEXT_PUBLIC_SUPABASE_ANON_KEY
|
|
ARG SUPABASE_SERVICE_ROLE_KEY
|
|
ENV NEXT_PUBLIC_SUPABASE_URL=$NEXT_PUBLIC_SUPABASE_URL
|
|
ENV NEXT_PUBLIC_SUPABASE_ANON_KEY=$NEXT_PUBLIC_SUPABASE_ANON_KEY
|
|
ENV SUPABASE_SERVICE_ROLE_KEY=$SUPABASE_SERVICE_ROLE_KEY
|
|
|
|
# Build the production Next.js bundle
|
|
RUN npm run build
|
|
|
|
# Expose Next.js port
|
|
EXPOSE 3000
|
|
|
|
ENV PORT=3000
|
|
ENV HOSTNAME="0.0.0.0"
|
|
|
|
# Start in production mode (no dev tools, no HMR, much faster)
|
|
CMD ["npm", "run", "start"]
|