diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..b9b4c73c --- /dev/null +++ b/.dockerignore @@ -0,0 +1,11 @@ +node_modules +.next +.git +.github +.vercel +.vscode +__tests__ +readme +*.md +.DS_Store +.env*.local diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..7d08f2a1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,35 @@ +FROM node:22-alpine AS base + +RUN corepack enable && corepack prepare pnpm@11.0.9 --activate + +FROM base AS deps +WORKDIR /app +COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./ +RUN pnpm install --frozen-lockfile + +FROM base AS builder +WORKDIR /app +COPY --from=deps /app/node_modules ./node_modules +COPY . . + +ARG NODE_OPTIONS="--max-old-space-size=1536" +RUN pnpm build + +FROM base AS runner +WORKDIR /app + +ENV NODE_ENV=production +ENV PORT=3000 +ENV HOSTNAME="0.0.0.0" + +RUN addgroup --system --gid 1001 nodejs && \ + adduser --system --uid 1001 nextjs + +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 + +CMD ["node", "server.js"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..0f7d2b3e --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,21 @@ +services: + photo-blog: + build: + context: . + args: + - NODE_OPTIONS=--max-old-space-size=1536 + extra_hosts: + - 'host.docker.internal:host-gateway' + container_name: photo-blog + restart: unless-stopped + ports: + - '127.0.0.1:3000:3000' + env_file: + - .env + extra_hosts: + - 'host.docker.internal:host-gateway' + healthcheck: + test: ['CMD', 'wget', '--no-verbose', '--tries=1', '--spider', 'http://localhost:3000/'] + interval: 30s + timeout: 10s + retries: 3 diff --git a/next.config.ts b/next.config.ts index 53dc488e..16a716ae 100644 --- a/next.config.ts +++ b/next.config.ts @@ -76,6 +76,7 @@ const IMAGE_QUALITY = : 75; const nextConfig: NextConfig = { + output: 'standalone', images: { imageSizes: [200], qualities: [75, IMAGE_QUALITY],