owl-stream/Dockerfile

47 lines
856 B
Docker

# Production Dockerfile for Next.js frontend
FROM node:20-alpine AS builder
WORKDIR /app
# Copy package files
COPY package*.json ./
COPY .npmrc ./
# Install dependencies
RUN npm ci
# Copy source code
COPY . .
# Build the application
ENV NEXT_TELEMETRY_DISABLED=1
RUN npm run build
# Production stage
FROM node:20-alpine AS runner
WORKDIR /app
# Copy necessary files from builder
COPY --from=builder /app/package*.json ./
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/public ./public
# Install only production dependencies
RUN npm ci --omit=dev
# Create non-root user
RUN addgroup --gid 1001 nodejs && \
adduser -D -u 1001 -G nodejs nextjs && \
chown -R nextjs:nodejs /app
USER nextjs
EXPOSE 8089
ENV PORT=8089
ENV HOSTNAME=0.0.0.0
CMD ["node", "server.js"]