chore: initialize project with Next.js and dependencies

This commit is contained in:
Greg 2025-05-18 15:48:01 +02:00
parent d71ba74659
commit 17914b78ce

View File

@ -1,19 +1,30 @@
# Production-ready Dockerfile for Next.js # Production-ready Dockerfile for Next.js
FROM node:20-alpine AS base FROM node:20-alpine AS base
# Set the working directory in the container
WORKDIR /app WORKDIR /app
ENV NODE_ENV=production ENV NODE_ENV=production
# Install dependencies only, then copy source for better caching # Copy package.json and package-lock.json from the 'myfavstuff' subdirectory
COPY package.json package-lock.json* ./ COPY myfavstuff/package.json myfavstuff/package-lock.json* ./
# Install dependencies
# Using npm ci for cleaner installs based on package-lock.json
RUN npm ci --omit=dev RUN npm ci --omit=dev
# Copy all files and build the Next.js app # Copy the rest of your app's source code from the 'myfavstuff' subdirectory
COPY . . COPY ./myfavstuff/. .
# Build the Next.js application
RUN npm run build RUN npm run build
# Use a non-root user for security # Use a non-root user for security
RUN addgroup -g 1001 -S nodejs && adduser -S nextjs -u 1001 RUN addgroup -g 1001 -S nodejs && adduser -S nextjs -u 1001
USER nextjs USER nextjs
# Expose port 3000 (default for Next.js)
EXPOSE 3000 EXPOSE 3000
# Command to run the application
CMD ["npm", "start"] CMD ["npm", "start"]