# Build stage FROM node:20-alpine AS builder WORKDIR /app # Copy package files and local dependency COPY package.json package-lock.json* ./ COPY cal-shared/ ./cal-shared/ # Replace Gitea archive URL with local copy for CI builds RUN sed -i 's|https://gitea.jeffemmett.com/jeffemmett/cal-shared/archive/main.tar.gz|file:./cal-shared|g' package.json # Install dependencies RUN npm install # Copy source files COPY . . # Build the application ENV BUILD_STANDALONE=true RUN npm run build # Production stage FROM node:20-alpine AS runner WORKDIR /app ENV NODE_ENV=production ENV NEXT_TELEMETRY_DISABLED=1 # Create non-root user RUN addgroup --system --gid 1001 nodejs RUN adduser --system --uid 1001 nextjs # Copy built application COPY --from=builder /app/public ./public COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static USER nextjs EXPOSE 3000 ENV PORT=3000 ENV HOSTNAME="0.0.0.0" CMD ["node", "server.js"]