You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to do my cypress component testings inside a docker container, however, after 3 hours I failed to run them successfully though I read dozens of blogs each one comes with a manner of configuring the testing.
This is my Dockerfile:
FROM cypress/included:13.6.4RUN $(npm bin)/cypress installFROM node:20-alpine AS base# Install dependencies only when neededFROM 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-compatWORKDIR /app# Install dependencies based on the preferred package managerCOPY package.json ./# You can use these package managers# 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; \# fiRUN npm install --legacy-peer-deps --verbose# Rebuild the source code only when neededFROM base AS builderWORKDIR /appCOPY --from=deps /app/node_modules ./node_modulesCOPY . .RUN npm run cypress-run-component# 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 1RUN npm run build# If using npm comment out above and use below instead# RUN npm run build# Production image, copy all the files and run nextFROM base AS runnerWORKDIR /appENV NODE_ENV production# Uncomment 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 ./public# Set the correct permission for prerender cacheRUN mkdir .nextRUN chown nextjs:nodejs .next# Automatically leverage output traces to reduce image size# https://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 3000# set hostname to localhostENV HOSTNAME "0.0.0.0"# server.js is created by next build from the standalone output# https://nextjs.org/docs/pages/api-reference/next-config-js/outputCMD ["node", "server.js"]
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi Everyone,
I wanted to do my cypress component testings inside a docker container, however, after 3 hours I failed to run them successfully though I read dozens of blogs each one comes with a manner of configuring the testing.
This is my
Dockerfile
:This is my
package.json
:The issue is when it reaches the script
cypress-run-component
, it throws this error:How can I install cypress and run test before running the build?
Beta Was this translation helpful? Give feedback.
All reactions