How to deploy on Google App Engine?

Deploying to Google App Engine is a fast and easy solution for hosting your universal Nuxt application on Google's Cloud Services.

In this guide, we build the application locally and then simply upload the entire project folder to Google App Engine. After the upload, Google App Engine will automatically start the start script in our package.json and your app will be available immediately.

Getting Started

Make sure you have a Google Cloud Account, a project and an empty Google App Engine app set up on Google App Engine. Furthermore, make sure to download and install the Cloud SDK (CLI) from Google as explained here and log into your Google Cloud Account.

Configure your application

All you need to add to your universal Nuxt app for deploying it to the App Engine is a file called app.yaml. Create a new file with that name in your root project directory and add the following content:

  1. runtime: nodejs10
  2. instance_class: F2
  3. handlers:
  4. - url: /_nuxt
  5. static_dir: .nuxt/dist/client
  6. secure: always
  7. - url: /(.*\.(gif|png|jpg|ico|txt))$
  8. static_files: static/\1
  9. upload: static/.*\.(gif|png|jpg|ico|txt)$
  10. secure: always
  11. - url: /.*
  12. script: auto
  13. secure: always
  14. env_variables:
  15. HOST: '0.0.0.0'
  16. NODE_ENV: 'production'

or for flexible environment the minimal configuration is:

  1. runtime: nodejs
  2. env: flex

Build and deploy the app

Now build your app with npm run build.

At this point, your app is ready to be uploaded to Google App Engine. Now just run the following command:

  1. gcloud app deploy app.yaml --project [project-id]

Voilà! Your Nuxt.js application is now hosted on Google App Engine!

Further Information

  • The instance_class attribute in your app.yaml file sets the class of your app instance. Instance F2 is not completely free, but has the minimum memory needed to run a Nuxt application.

Make sure to put the project-id and not the project-name in the deploy command. These are two different things but easy to mix up.