付费cms docker构建错误:无法解决:存档/焦油:未知文件模式?rwxr-xr-x

问题描述 投票:0回答:0
output: 'standalone'

  1. const nextConfig = { images: { remotePatterns: [ ...[NEXT_PUBLIC_SERVER_URL /* 'https://example.com' */].map((item) => { const url = new URL(item) return { hostname: url.hostname, protocol: url.protocol.replace(':', ''), } }), ], }, reactStrictMode: true, redirects, output: 'standalone', }
    
    
  2. 对于Azure Cosmos DB集成,我已经进行了以下更改: 在buildconfig pareload.config.ts中添加
transactionOptions: false

    db: mongooseAdapter({ url: process.env.DATABASE_URI || '', transactionOptions: false, }),
  1. 也添加到buildConfig。
    lastly,这是我的Dockerfile:
  2. indexSortableFields: true
这是我的docker-compose.yml:

# To use this Dockerfile, you have to set `output: 'standalone'` in your next.config.js file. # From https://github.com/vercel/next.js/blob/canary/examples/with-docker/Dockerfile FROM node:22.12.0-alpine 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 yarn.lock* package-lock.json* pnpm-lock.yaml* ./ RUN \ if [ -f yarn.lock ]; then yarn --frozen-lockfile; \ elif [ -f package-lock.json ]; then npm ci; \ elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \ else echo "Lockfile not found." && exit 1; \ fi # 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 yarn.lock ]; then yarn run build; \ elif [ -f package-lock.json ]; then npm run build; \ elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm 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 # Remove this line if you do not have this folder 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 ENV HOSTNAME="0.0.0.0" CMD ["node", "server.js"]

我用来尝试构建此Docker映像的命令:

version: '3'

services:
  payload:
    image: node:18-alpine
    ports:
      - '3000:3000'
    volumes:
      - .:/home/node/app
      - node_modules:/home/node/app/node_modules
    working_dir: /home/node/app/
    command: sh -c "yarn install && yarn dev"
    depends_on:
      - mongo
    env_file:
      - .env

  mongo:
    image: mongo:latest
    ports:
      - '27017:27017'
    command:
      - --storageEngine=wiredTiger
    volumes:
      - data:/data/db
    logging:
      driver: none

volumes:
  data:
  node_modules:

az login

    az acr login --name <acr-name>
  1. 
    
  2. 最后,这是我遇到的完整错误:
  3. docker build -t <acr>/<build-name>:<version-tag> .
    docker版本:
  4. [+] Building 491.8s (10/20) docker:desktop-linux => [internal] load build definition from Dockerfile 0.0s => => transferring dockerfile: 2.53kB 0.0s => [internal] load metadata for docker.io/library/node:22.12.0-alpine 0.0s => [internal] load .dockerignore 0.0s => => transferring context: 2B 0.0s => ERROR [internal] load build context 488.9s => => transferring context: 1.45GB 488.9s => CACHED [base 1/1] FROM docker.io/library/node:22.12.0-alpine@sha256:51eff88af6dff26f59316b6e356188ffa2c422bd3c3b76f2556a2e7e89d080bd => => transferring dockerfile: 2.53kB 0.0s fa2c422bd3c3b76f2556a2e7e89d080bd => [internal] load metadata for docker.io/library/node:22.12.0-alpine 0.0s => [internal] load .dockerignore 0.0s 2.7s => => resolve docker.io/library/node:22.12.0-alpine@sha256:51eff88af6dff26f59316b6e356188ffa2c422bd3c3b76f2556a2e7e89d080bd 2.7s => CACHED [builder 1/4] WORKDIR /app 0.0s => [runner 2/8] RUN addgroup --system --gid 1001 nodejs 0.8s => [deps 1/4] RUN apk add --no-cache libc6-compat 1.8s => [runner 3/8] RUN adduser --system --uid 1001 nextjs 0.7s => [deps 2/4] WORKDIR /app 0.0s ------ > [internal] load build context: ------ ERROR: failed to solve: archive/tar: unknown file mode ?rwxr-xr-x
  5.     
通过在.dockerignore文件中添加node_modules并使用npm安装pnpm

来解决此问题。


node.js docker docker-compose dockerfile payload-cms
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.