retest / Dockerfile
veltrixcode's picture
Upload 75 files
ebde876 verified
Raw History Blame Contribute Delete
2 kB
# ==========================================
# STAGE 1: Builder
# ==========================================
FROM ubuntu:22.04 AS builder
# Prevent interactive prompts
ENV DEBIAN_FRONTEND=noninteractive
# Update system and install build dependencies
# curl, ca-certificates, gnupg: for Node.js
# openssl: for Prisma
RUN apt-get update && apt-get install -y \
curl \
ca-certificates \
openssl \
gnupg \
&& rm -rf /var/lib/apt/lists/*
# Install Node.js 20 (LTS)
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
&& apt-get install -y nodejs \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy package files first for caching
COPY package*.json ./
COPY prisma ./prisma/
# Install dependencies (including devDependencies for build)
RUN npm install
# Copy source code
COPY . .
# Generate Prisma Client and Build
# Prisma client will be generated for "native" and "debian-openssl-*" targets per schema
RUN npx prisma generate
RUN npm run build
# ==========================================
# STAGE 2: Runner
# ==========================================
FROM ubuntu:22.04 AS runner
# Prevent interactive prompts
ENV DEBIAN_FRONTEND=noninteractive
# Update system and install runtime dependencies
# We need openssl for Prisma runtime
RUN apt-get update && apt-get install -y \
curl \
ca-certificates \
openssl \
&& rm -rf /var/lib/apt/lists/*
# Install Node.js 20 (LTS) - Optimized for runtime
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
&& apt-get install -y nodejs \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Set environment to production
ENV NODE_ENV=production
# Copy built artifacts from builder stage
# We use the specific path from the builder's output
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/.next/standalone ./
# Expose port
EXPOSE 3000
ENV HOSTNAME="0.0.0.0"
ENV PORT=3000
# Start server
CMD ["node", "server.js"]