From 15235cd5f9ea3a368be740e01cf89e1561bbca51 Mon Sep 17 00:00:00 2001 From: nicholai Date: Wed, 10 Sep 2025 05:39:31 -0600 Subject: [PATCH] Add Dockerfile and update README with deployment instructions --- Dockerfile | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 28 ++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6fd4301 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,52 @@ +# Multi-stage Dockerfile for Next.js Application + +# Build stage +FROM node:24-alpine AS builder + +# Set working directory +WORKDIR /app + +# Copy package files +COPY package*.json ./ + +# Install dependencies +RUN npm ci --only=production + +# Copy source code +COPY . . + +# Build the Next.js application +RUN npm run build + +# Production stage +FROM node:24-alpine AS production + +# Set working directory +WORKDIR /app + +# Create non-root user +RUN addgroup -g 1001 -S nodejs && \ + adduser -S nextjs -u 1001 + +# Copy dependencies from builder stage +COPY --from=builder /app/node_modules ./node_modules +COPY --from=builder /app/.next ./.next +COPY --from=builder /app/package.json ./package.json + +# Copy source code +COPY --from=builder /app/.env ./.env +COPY --from=builder /app/public ./public + +# Change ownership +RUN chown -R nextjs:nodejs /app +USER nextjs + +# Expose port +EXPOSE 3000 + +# Health check +HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \ + CMD curl -f http://localhost:3000/health || exit 1 + +# Start command +CMD ["npm", "start"] diff --git a/README.md b/README.md index 08e6c51..b347ce1 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,34 @@ npm run build ### Deployment +#### Docker Deployment + +This project includes a Dockerfile for containerized deployment. To build and run the application using Docker: + +1. Build the image: +```bash +docker build -t nicholais-website . +``` + +2. Run the container: +```bash +docker run -p 3000:3000 nicholais-website +``` + +3. Or with environment variables: +```bash +docker run -p 3000:3000 -e NODE_ENV=production nicholais-website +``` + +#### Environment Variables + +The application supports the following environment variables: + +| Variable | Description | Default | +|----------|-------------|---------| +| `NODE_ENV` | Node.js environment | `development` | +| `PORT` | Port to run the server on | `3000` | + ## License This project is open source, take it. I don't give a fuck. I am not your dad.