1

To host an Angular 4 app (built with angular-cli) on App Engine I built the following:

service: stage
runtime: python27
api_version: 1
threadsafe: true

skip_files:
- ^(?!dist)  # Skip any files not in the dist folder

handlers:
# Routing for bundles to serve directly
- url: /((?:inline|main|polyfills|styles|vendor)\.[a-z0-9]+\.bundle\.js)
  secure: always
  redirect_http_response_code: 301
  static_files: dist/\1
  upload: dist/.*

# Routing for a prod styles.bundle.css to serve directly
- url: /(styles\.[a-z0-9]+\.bundle\.css)
  secure: always
  redirect_http_response_code: 301
  static_files: dist/\1
  upload: dist/.*

# Routing for typedoc, assets and favicon.ico to serve directly
- url: /((?:assets|docs)/.*|favicon\.ico)
  secure: always
  redirect_http_response_code: 301
  static_files: dist/\1
  upload: dist/.*

# Any other requests are routed to index.html for angular to handle so we don't need hash URLs
- url: /.*
  secure: always
  redirect_http_response_code: 301
  static_files: dist/index.html
  upload: dist/index\.html
  http_headers:
    Strict-Transport-Security: max-age=31536000; includeSubDomains
    X-Frame-Options: DENY

As you can see I am only using the static_files endpoints, and there is not a python app involved at all. I did this in order to have an app running under https in Google Cloud Platform. But I find the Google documentation to be confusing, especially when I don't know what tools are available. Is there a better way to do this? Are there any pitfalls with this method I should be wary of?

Rob
  • 3,687
  • 2
  • 32
  • 40
  • hey Rob, do you have any updates on this? it is really frustrating that there is no clear steps to make the angular app ready for GCP app engine. – Elio Khattar Aug 19 '17 at 18:17
  • I've moved on from this project, but others seem to like this solution and I know of no reason why it shouldn't be used. https://stackoverflow.com/questions/39782506/deploying-basic-angular-2-app-to-google-app-engine/44730124#44730124 – Rob Aug 21 '17 at 14:16

1 Answers1

1

These are the basic configuration which is needed on app engine

#Configuration of runtime parameters
runtime: custom
env: flex
service: ui-version

handlers:
- url: /.*
  script: this field is required, but ignored
  secure: always  # Require HTTPS

health_check:
  enable_health_check: False
  check_interval_sec: 5
  timeout_sec: 4
  unhealthy_threshold: 2
  healthy_threshold: 2

manual_scaling:
  instances: 1

resources:
  cpu: 1
  memory_gb: 4.0
  disk_size_gb: 20
Ashish Kumar
  • 542
  • 4
  • 20