Quantcast
Channel: Active questions tagged containers - DevOps Stack Exchange
Viewing all articles
Browse latest Browse all 164

Docker build fails on GitHub Actions

$
0
0

I'm getting an error when I run a Docker build and push script through GitHub Actions. This is the error:

# ------Dockerfile:48# --------------------46 |     RUN adduser --system --uid 1001 nextjs47 |     48 | >>> COPY --from=builder /app/public ./public49 |     50 |     # Set the correct permission for prerender cache# --------------------ERROR: failed to solve: failed to compute cache key: failed to calculate checksum of ref x-x-x-x-x::x: "/app/public": not found

I think it might have to do with the files being built on the GH server and the script can't find the right context. Here's my workflow file:

name: Docker Image CI for GHCRon: pushjobs:build_and_publish:runs-on: ubuntu-lateststeps:uses: actions/checkout@v4name: Build and push the imagerun: |docker login --username x --password ${{ secrets.GH_PAT }} ghcr.iodocker build . --tag ghcr.io/x/xdocker push ghcr.io/x/x:latest

This Dockerfile is taken straight from Next.js docs:

FROM --platform=linux/amd64 node:18-alpine AS baseInstall dependencies only when neededFROM base AS depsCheck https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.RUN apk add --no-cache libc6-compatWORKDIR /appInstall dependencies based on the preferred package managerCOPY 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; \fiRebuild the source code only when neededFROM base AS builderWORKDIR /appCOPY --from=deps /app/node_modules ./node_modulesCOPY . .Next.js collects completely anonymous telemetry data about general usage.Learn more here: https://nextjs.org/telemetryUncomment the following line in case you want to disable telemetry during the build.ENV NEXT_TELEMETRY_DISABLED 1RUN \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; \fiProduction image, copy all the files and run nextFROM base AS runnerWORKDIR /appENV NODE_ENV productionUncomment the following line in case you want to disable telemetry during runtime.ENV NEXT_TELEMETRY_DISABLED 1RUN addgroup --system --gid 1001 nodejsRUN adduser --system --uid 1001 nextjsCOPY --from=builder /app/public ./publicSet the correct permission for prerender cacheRUN mkdir .nextRUN chown nextjs:nodejs .nextAutomatically leverage output traces to reduce image sizehttps://nextjs.org/docs/advanced-features/output-file-tracingCOPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/staticUSER nextjsEXPOSE 3000ENV PORT 3000set hostname to localhostENV HOSTNAME "0.0.0.0"server.js is created by next build from the standalone outputhttps://nextjs.org/docs/pages/api-reference/next-config-js/outputCMD ["node", "server.js"]

I tried adding context to the build and push but got syntax errors.


Viewing all articles
Browse latest Browse all 164

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>