Issue when deploying to Google Cloud Run
See original GitHub issueWhat version of Next.js are you using?
11.1.2
What version of Node.js are you using?
12.17
What browser are you using?
Chrome
What operating system are you using?
Windows
How are you deploying your application?
Google Cloud
Describe the Bug
When I build my application for deployment with Google Cloud Build, I receive no errors and my Docker image builds correctly. However, when I go to deploy the image with Google Cloud Run, I receive the error
Error: Cannot find module '/app/.next/server/middleware-manifest.json'
which is strange, considering that I didn’t create any middleware for my application.
Expected Behavior
The application should run correctly with no issue.
To Reproduce
Dockerfile:
# Install dependencies only when needed
FROM node:14.17-alpine 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
COPY package.json package-lock.json ./
RUN npm ci
# Rebuild the source code only when needed
FROM node:14.17-alpine AS builder
WORKDIR /app
ENV NODE_ENV=production
###########################################
# There are other ENV variables here that I have removed
###########################################
COPY . .
COPY --from=deps /app/node_modules ./node_modules
RUN npm run build && npm install
# Production image, copy all the files and run next
FROM node:14.17-alpine AS runner
WORKDIR /app
ENV NODE_ENV production
RUN addgroup -g 1001 -S nodejs
RUN adduser -S nextjs -u 1001
# You only need to copy next.config.js if you are NOT using the default configuration
COPY --from=builder /app/next.config.js ./
COPY --from=builder /app/next-i18next.config.js ./
COPY --from=builder /app/htmlserializer.js ./
COPY --from=builder /app/tailwind.config.js ./
COPY --from=builder /app/firebaseConfig.js ./
COPY --from=builder /app/postcss.config.js ./
COPY --from=builder /app/public ./public
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
USER nextjs
EXPOSE 3000
ENV PORT 3000
# 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.
# ENV NEXT_TELEMETRY_DISABLED 1
CMD ["node_modules/.bin/next", "start"]
cloud-build.yaml
steps:
- name: 'gcr.io/cloud-builders/docker'
entrypoint: 'bash'
args:
- '-c'
- |
docker pull gcr.io/[MY PROJECT ID]/website:latest || exit 0
- name: gcr.io/cloud-builders/docker
timeout: 1200s
args:
[
'build',
'-f',
'Dockerfile',
'-t',
'gcr.io/[MY PROJECT ID]/website',
'--cache-from',
'gcr.io/[MY PROJECT ID]/website:latest',
'.',
]
timeout: 1200s
images:
- gcr.io/[MY PROJECT ID]/website
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Troubleshoot Cloud Run issues
The following error occurs when you try to deploy or try to call another Google Cloud API: The server has encountered an internal...
Read more >Deploying to Google Cloud Platform (GCP) - Quarkus
Deploying a Docker image to Google Cloud Run ... Quarkus supports deploying your application to Google Cloud Functions via the following extensions:.
Read more >Deploy to Cloud Run from Cloud Deploy - Medium
Cloud Deploy allows you to create and operate deployment pipelines without the need to host infrastructure and deploy application releases to Google Kubernetes ......
Read more >Tutorial: Deploying Cloud Run Jobs | by Austen Novis
Cloud Run jobs are a new way to execute code in containers on the Google Cloud Platform (GCP), and are a good fit...
Read more >Incidents - Google Cloud Service Health
We are investigating a potential issue with multiple Google Cloud services. 14 Nov 2022 ... Global: Cloud Run deployment time outs and failures,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I was on Next version 11.1, and I opted to upgrade my node version to LTS 16 and Next to 12.07. That seemed to do the trick! Thank you very much for your help!
I didn’t try building it locally at first, I was using Google Cloud Build to achieve that. I’ll go ahead and install docker on my system.