Deployment on Cloud Run

Hey so I tried following this guide: https://cloud.google.com/run/docs/quickstarts/frameworks/deploy-nuxtjs-service to deploy my nuxt 3 app to cloud run. while building the image worked flawlessly, clod run tries to execute "yarn start" in order to start the app. It appears something has changed since this guide was made and I will need some assistance to get it running. I am using Nuxt with the v4-compat template and the ui module. so far nothing has been added to the app.
Google Cloud
Quickstart: Deploy a Nuxt.js service to Cloud Run  |  Cloud Run Doc...
Learn how to deploy a service to Cloud Run using Nuxt.js and a container image.
2 Replies
kapa.ai
kapa.ai4w ago
Hi @Just Simeon. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- It seems the guide you're referring to might be outdated for Nuxt 3, especially with the v4-compat template. Let me provide you with some updated information based on the knowledge sources available. For Nuxt 3 deployments, the start command has changed. Instead of yarn start, you should use node .output/server/index.mjs to start your Nuxt 3 application Stack Overflow Post (https://stackoverflow.com/questions/77517718). To deploy your Nuxt 3 application to Cloud Run, you'll need to make some adjustments to your configuration. Here's what you can do: 1. Update your package.json file to include the correct start script:
{
"scripts": {
"start": "node .output/server/index.mjs"
}
}
{
"scripts": {
"start": "node .output/server/index.mjs"
}
}
2. In your Dockerfile, ensure you're setting the correct environment variables and start command:
ENV HOST=0.0.0.0 PORT=8080 NODE_ENV=production
CMD ["node", ".output/server/index.mjs"]
ENV HOST=0.0.0.0 PORT=8080 NODE_ENV=production
CMD ["node", ".output/server/index.mjs"]
3. When building your Docker image, make sure you're using the correct build command for Nuxt 3. You might want to use nuxi build instead of nuxt build if you're using the latest Nuxt CLI. 4. If you're still encountering issues, you might want to consider using the Nitro deployment preset for Node.js servers. You can set this in your nuxt.config.ts file Docs > Getting-started > Deployment (https://nuxt.com/docs/getting-started/deployment#hosting-providers):
export default defineNuxtConfig({
nitro: {
preset: 'node-server'
}
})
export default defineNuxtConfig({
nitro: {
preset: 'node-server'
}
})
5. Given that you're using the v4-compat template and the UI module, make sure these are properly configured in your nuxt.config.ts file Getting-started (https://ui.nuxt.com/getting-started/installation):
export default defineNuxtConfig({
modules: ['@nuxt/ui'],
future: {
compatibilityVersion: 4,
}
})
export default defineNuxtConfig({
modules: ['@nuxt/ui'],
future: {
compatibilityVersion: 4,
}
})
If you're still facing issues after making these changes, you might need to review your Dockerfile and Cloud Run configuration to ensure they're compatible with Nuxt 3 and the v4-compat template. Unfortunately, I don't have specific information about Cloud Run configurations in the provided knowledge sources. Remember to test your application locally using the production build before deploying to Cloud Run to ensure everything works as expected. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai4w ago
<@294593079812292609> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Want results from more Discord servers?
Add your server