Add Docker configuration for Next.js application

This commit is contained in:
2026-05-19 19:37:42 +02:00
parent 75d80084b6
commit cd6378351e
3 changed files with 69 additions and 1 deletions
+33
View File
@@ -0,0 +1,33 @@
FROM node:20-alpine AS base
FROM base AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY package.json package-lock.json* ./
RUN npm ci
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN npx prisma generate
RUN npm run build
FROM base AS runner
WORKDIR /app
ENV NODE_ENV production
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/prisma ./prisma
USER nextjs
EXPOSE 3000
ENV PORT=3000
CMD ["node", "server.js"]
+33
View File
@@ -0,0 +1,33 @@
services:
app:
build:
context: .
dockerfile: Dockerfile
ports:
- "3000:3000"
environment:
DATABASE_URL: postgresql://bikeapp:bikeapp@db:5432/bikeapp
JWT_SECRET: ${JWT_SECRET:-your-super-secret-jwt-key-change-in-production}
depends_on:
db:
condition: service_healthy
restart: unless-stopped
db:
image: postgres:16-alpine
environment:
POSTGRES_USER: bikeapp
POSTGRES_PASSWORD: bikeapp
POSTGRES_DB: bikeapp
volumes:
- postgres_data:/var/lib/postgresql/data
ports:
- "5432:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U bikeapp -d bikeapp"]
interval: 5s
timeout: 5s
retries: 5
volumes:
postgres_data:
+3 -1
View File
@@ -1,4 +1,6 @@
/** @type {import('next').NextConfig} */ /** @type {import('next').NextConfig} */
const nextConfig = {}; const nextConfig = {
output: "standalone",
};
export default nextConfig; export default nextConfig;