diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..cefef49 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +node_modules +.next +.vscode +.git \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 2ad3de0..d5542e0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,39 +1,14 @@ -FROM node:18-alpine AS deps -RUN apk add --no-cache libc6-compat +FROM node:18-alpine as builder WORKDIR /app - -COPY package.json package-lock.json ./ -RUN npm ci - -# Rebuild the source code only when needed -FROM node:18-alpine AS builder -WORKDIR /app - COPY . . -COPY --from=deps /app/node_modules ./node_modules - -ENV NEXT_TELEMETRY_DISABLED 1 - +RUN npm install --include=dev RUN npm run build FROM node:18-alpine AS runner WORKDIR /app - -ENV NODE_ENV production -ENV NEXT_TELEMETRY_DISABLED 1 - -RUN addgroup --system --gid 1001 nodejs -RUN adduser --system --uid 1001 nextjs - -COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next -COPY --from=builder /app/node_modules ./node_modules -COPY --from=builder /app/package.json ./package.json +COPY --from=builder /app/.next/standalone . COPY --from=builder /app/public ./public - -USER nextjs +COPY --from=builder /app/.next/static ./.next/static EXPOSE 3000 - -ENV PORT 3000 - -CMD ["npm", "start"] +CMD ["node", "server.js"] \ No newline at end of file diff --git a/next.config.js b/next.config.js index 7ed729d..74d32f4 100644 --- a/next.config.js +++ b/next.config.js @@ -5,6 +5,7 @@ const nextConfig = { // building the app. Since pdfjs-dist is only used on client side, we disable // the canvas package for webpack // https://github.com/mozilla/pdf.js/issues/16214 + output: 'standalone', webpack: (config) => { // Setting resolve.alias to false tells webpack to ignore a module // https://webpack.js.org/configuration/resolve/#resolvealias