diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..7d030c5 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,9 @@ +Dockerfile +.dockerignore +node_modules +npm-debug.log +README.md +.env* +.next +.git +# Add more files and directories according to your porject needs diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4c118a5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,45 @@ +# syntax = docker/dockerfile:1 + +FROM node:22-slim AS base + +ARG PORT=3000 + +ENV NEXT_TELEMETRY_DISABLED=1 + +WORKDIR /app + +# Dependencies +FROM base AS dependencies + +COPY package.json package-lock.json ./ +RUN npm ci + +# Build +FROM base AS build + +COPY --from=dependencies /app/node_modules ./node_modules +COPY . . + +RUN npm run build + +# Run +FROM base AS run + +ENV NODE_ENV=production +ENV PORT=$PORT + +RUN addgroup --system --gid 1001 nodejs +RUN adduser --system --uid 1001 nextjs +RUN mkdir .next +RUN chown nextjs:nodejs .next + +COPY --from=build /app/public ./public +COPY --from=build --chown=nextjs:nodejs /app/.next/standalone ./ +COPY --from=build --chown=nextjs:nodejs /app/.next/static ./.next/static + +USER nextjs + +EXPOSE $PORT + +ENV HOSTNAME="0.0.0.0" +CMD ["node", "server.js"] \ No newline at end of file diff --git a/next.config.ts b/next.config.ts index c3b9bc0..3a6cd32 100644 --- a/next.config.ts +++ b/next.config.ts @@ -1,6 +1,7 @@ import type { NextConfig } from "next"; const nextConfig: NextConfig = { + output: "standalone", images: { remotePatterns: [ {