Giter Club home page Giter Club logo

Comments (24)

MrOxMasTer avatar MrOxMasTer commented on June 2, 2024

prebuild/node-gyp-build#53

from node-argon2.

MrOxMasTer avatar MrOxMasTer commented on June 2, 2024

alpine3.18-3.19 don't work

from node-argon2.

ranisalt avatar ranisalt commented on June 2, 2024

Can you share a minimal Dockerfile + package.json that triggers this issue?

from node-argon2.

MrOxMasTer avatar MrOxMasTer commented on June 2, 2024

Can you share a minimal Dockerfile + package.json that triggers this issue?

{
  "name": "shopco",
  "version": "0.1.0",
  "private": true,
  "type": "module",
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint",
    "migration:generate": "drizzle-kit generate:pg",
    "migration:push": "drizzle-kit push:pg",
    "studio": "drizzle-kit studio --host 127.0.0.1",
    "build:icons": "npx tsx ./build-icons.mts",
    "sly": "pnpm dlx @sly-cli/sly add"
  },
  "dependencies": {
    "@auth/drizzle-adapter": "^0.8.0",
    "@hookform/resolvers": "^3.3.4",
    "@radix-ui/react-dialog": "^1.0.5",
    "@radix-ui/react-slot": "^1.0.2",
    "@t3-oss/env-nextjs": "^0.9.2",
    "argon2": "^0.40.1",
    "class-variance-authority": "^0.7.0",
    "clsx": "^2.1.0",
    "drizzle-orm": "^0.30.2",
    "drizzle-zod": "^0.5.1",
    "embla-carousel-autoplay": "8.0.0-rc17",
    "embla-carousel-react": "8.0.0-rc17",
    "ky": "^1.2.2",
    "nanoid": "^5.0.6",
    "next": "14.2.1",
    "next-auth": "5.0.0-beta.16",
    "next-themes": "^0.3.0",
    "pg": "^8.11.3",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-focus-lock": "^2.11.2",
    "react-hook-form": "^7.51.2",
    "redis": "^4.6.13",
    "server-only": "^0.0.1",
    "sharp": "^0.33.2",
    "sonner": "^1.4.3",
    "tailwind-merge": "^2.2.1",
    "tailwindcss-animate": "^1.0.7",
    "zod": "^3.22.4",
    "zustand": "^4.5.2"
  },
  "devDependencies": {
    "@conarti/eslint-plugin-feature-sliced": "^1.0.5",
    "@sly-cli/sly": "^1.10.0",
    "@types/fs-extra": "^11.0.4",
    "@types/node": "^20.11.28",
    "@types/pg": "^8.11.2",
    "@types/react": "^18.2.66",
    "@types/react-dom": "^18.2.22",
    "@typescript-eslint/eslint-plugin": "^6.21.0",
    "@typescript-eslint/parser": "^6.21.0",
    "autoprefixer": "^10.4.18",
    "cssnano": "^6.1.0",
    "drizzle-kit": "^0.20.14",
    "eslint": "^8.57.0",
    "eslint-config-next": "14.1.3",
    "eslint-config-prettier": "^9.1.0",
    "eslint-plugin-drizzle": "^0.2.3",
    "eslint-plugin-import": "^2.29.1",
    "eslint-plugin-promise": "^6.1.1",
    "eslint-plugin-tailwindcss": "^3.14.3",
    "fs-extra": "^11.2.0",
    "glob": "^10.3.10",
    "jiti": "^1.21.0",
    "lucide-react": "^0.303.0",
    "node-html-parser": "^6.1.12",
    "postcss": "^8.4.35",
    "postcss-flexbugs-fixes": "^5.0.2",
    "postcss-preset-env": "^9.4.0",
    "prettier": "^3.2.5",
    "prettier-plugin-tailwindcss": "^0.5.12",
    "react-devtools": "^5.0.2",
    "stylelint": "^16.3.0",
    "stylelint-config-standard": "^36.0.0",
    "stylelint-order": "^6.0.4",
    "stylelint-selector-bem-pattern": "^4.0.0",
    "svgo": "^3.2.0",
    "tailwindcss": "^3.4.1",
    "tailwindcss-debug-screens": "^2.2.1",
    "typescript": "^5.4.2"
  }
}
FROM node:20-alpine3.18 AS base

# Install dependencies only when needed
FROM base AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /app

# Install dependencies based on the preferred package manager
COPY package.json pnpm-lock.yaml* yarn.lock* package-lock.json* ./
RUN \
  if [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \
  elif [ -f yarn.lock ]; then yarn --frozen-lockfile; \
  elif [ -f package-lock.json ]; then npm ci; \
  else echo "Lockfile not found." && exit 1; \
  fi

# RUN apk add build-base
# RUN gcc -v
RUN npm i -g node-gyp
RUN pnpm i argon2

# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .

# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry during the build.
# ENV NEXT_TELEMETRY_DISABLED 1

RUN \
  if [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \
  elif [ -f yarn.lock ]; then yarn run build; \
  elif [ -f package-lock.json ]; then npm run build; \
  else echo "Lockfile not found." && exit 1; \
  fi

# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /app

ENV NODE_ENV production
# Uncomment the following line in case you want to disable telemetry during runtime.
# ENV NEXT_TELEMETRY_DISABLED 1

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

COPY --from=builder /app/public ./public

# Set the correct permission for prerender cache
RUN mkdir .next
RUN chown nextjs:nodejs .next

# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static

USER nextjs

EXPOSE 3000

ENV PORT 3000

# server.js is created by next build from the standalone output
# https://nextjs.org/docs/pages/api-reference/next-config-js/output
CMD HOSTNAME="0.0.0.0" node server.js

from node-argon2.

MrOxMasTer avatar MrOxMasTer commented on June 2, 2024

prebuild/node-gyp-build#53

from node-argon2.

ranisalt avatar ranisalt commented on June 2, 2024

You seem to be using Next.js standalone mode, which notably fails to find anything that's not explicitly required when building - since the argon2 module needs to dynamically choose the binary, it fails to get picked.

You likely need to use outputFileTracingIncludes in one of your endpoints to include ./node_modules/argon2/** or just copy the entire node_modules/argon2 folder to the runner image

from node-argon2.

MrOxMasTer avatar MrOxMasTer commented on June 2, 2024

Owner

Tried to add for all pages and this is what came out. I can't enable for any specific point because argon is used in middleware for authorisation

experimental: {
    outputFileTracingIncludes: {
      '/': ['./node_modules/argon2/**'],
    },
  }
frontend  |  ⨯ Error: Cannot find module '@phc/format'
frontend  | Require stack:
frontend  | - /app/node_modules/argon2/argon2.cjs
frontend  | - /app/.next/server/app/(main)/auth/page.js
frontend  | - /app/node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/next/dist/server/require.js
frontend  | - /app/node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/next/dist/server/next-server.js
frontend  | - /app/node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/next/dist/server/next.js
frontend  | - /app/server.js
frontend  |     at Module._resolveFilename (node:internal/modules/cjs/loader:1143:15)
frontend  |     at /app/node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/next/dist/server/require-hook.js:55:36
frontend  |     at Module._load (node:internal/modules/cjs/loader:984:27)
frontend  |     at Module.require (node:internal/modules/cjs/loader:1231:19)
frontend  |     at mod.require (/app/node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/next/dist/server/require-hook.js:65:28)
frontend  |     at require (node:internal/modules/helpers:179:18)
frontend  |     at Object.<anonymous> (/app/node_modules/argon2/argon2.cjs:4:36)
frontend  |     at Module._compile (node:internal/modules/cjs/loader:1369:14)
frontend  |     at Module._extensions..js (node:internal/modules/cjs/loader:1427:10)
frontend  |     at Module.load (node:internal/modules/cjs/loader:1206:32) {
frontend  |   code: 'MODULE_NOT_FOUND',
frontend  |   requireStack: [
frontend  |     '/app/node_modules/argon2/argon2.cjs',
frontend  |     '/app/.next/server/app/(main)/auth/page.js',
frontend  |     '/app/node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/next/dist/server/require.js',
frontend  |     '/app/node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/next/dist/server/next-server.js',
frontend  |     '/app/node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/next/dist/server/next.js',
frontend  |     '/app/server.js'
frontend  |   ]
frontend  | }

I'm gonna try to copy the folder

from node-argon2.

MrOxMasTer avatar MrOxMasTer commented on June 2, 2024

Could this problem be due to the use of pnpm? It's just that it creates symbolic links and it's weird to copy a folder into the runner
image

from node-argon2.

MrOxMasTer avatar MrOxMasTer commented on June 2, 2024

maybe make some "argon2.config.js" that describes the binaries that will be included in the final build? Or create your own argon2 instance with the configuration in it. In my opinion this would eliminate the problem that binaries may not make it into the final build and thus not load unnecessary binaries that are not needed by a particular distribution (e.g. alpine does not need a binary for ubuntu).

from node-argon2.

MrOxMasTer avatar MrOxMasTer commented on June 2, 2024

Do I understand correctly that these are the binaries that should be included in the final build? If so, they kind of are

image

And with it switched off outputFileTracingIncludes

image

from node-argon2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.