LoginSignup
12
8

More than 5 years have passed since last update.

Nuxt.jsをGAEにSSRとしてデプロイする際の注意点

Last updated at Posted at 2018-12-06

はじめに

先日、GAEがNode.js 10に対応に対応されました。
https://cloud.google.com/appengine/docs/standard/nodejs/

Qiita記事を見ると、Nuxt.jsをGAEにデプロイする際の app.yamlファイルの記述が単純でそのままSSRとしてデプロイしてしまうとすぐにメモリ不足で落ちて500エラーとなります。

app.yaml
runtime: nodejs8
env: standard

解決方法

以下のapp.yamlにするとある程度のメモリ不足は回避出来ます。

app.yamlに関する情報はこちらに記載されています。
https://cloud.google.com/appengine/docs/standard/nodejs/config/appref

app.yaml
runtime: nodejs10

instance_class: F2

handlers:
  - url: /_nuxt
    static_dir: .nuxt/dist/client

  - url: /(.*\.(gif|png|jpg|ico|txt))$
    static_files: static/\1
    upload: static/.*\.(gif|png|jpg|ico|txt)$

  - url: /.*
    script: auto
    secure: always

app.yamlの記述について

runtime

Nuxt.js v2だと思いますので、nodejs10にしましょう。

instance_class

Nuxt.jsでSSRする際はデフォルトのインスタンスF1 だと厳しいので F2 にしましょう。
詳しい料金表はこちらです。
https://cloud.google.com/appengine/pricing

handlers

handlersオプションを使用して、静的ファイルをCDN配信する事が出来ます。
※ここ凄い重要です。

handlersについて
https://cloud.google.com/appengine/docs/standard/python/config/appref#handlers_element

これでも厳しいって方は scaling_elements 等を設定して試行錯誤する必要があると思います。
https://cloud.google.com/appengine/docs/standard/python/config/appref#scaling_elements

12
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
8