Angel Cuenca
Angel Cuenca

Reputation: 1659

GCP flexible environment: Configure app.yaml to run multiple services

I have configured two services which one of them is the default. But when consulting the https://gcpdev.company.com/one service through DNS, it cannot reach the project files. For example:

If I type directly this url, 500 error returns:

https://gcpdev.company.com/vendor-es2017.65ff9b5300ddf6707a5c.js

The correct one that opens the file is:

https://gcpdev.company.com/one/vendor-es2017.65ff9b5300ddf6707a5c.js

There is something wrong with my configs? these are the files for default project:

dispatch.yaml

dispatch:
  - url: "gcpdev.company.com/one/*"
    service: default
  - url: "gcpdev.company.com/two/*"
    service: two-ui

app.yaml

runtime: nodejs12    
service: default

handlers:
  - url: /one/(.*\.(gif|png|jpg|less|json|woff|woff2|ttf|eot|scss|css|js|ico|svg)(|\.map))$
    static_files: dist/\1
    upload: dist/(.*)(|\.map)

  - url: /one/assets/data/appConfig.json
    static_files: dist/assets/data/appConfig.json
    upload: dist/assets/data/appConfig.json

  - url: /one/(.*)
    static_files: dist/index.html
    upload: dist/index.html

For two-ui project I have the same dispatch.yaml and similar app.yaml:

 runtime: nodejs12        
 service: two-ui
    
 handlers:
   - url: /two/(.*\.(gif|png|jpg|less|json|woff|woff2|ttf|eot|scss|css|js|ico|svg)(|\.map))$
     static_files: dist/\1
     upload: dist/(.*)(|\.map)
    
   - url: /two/assets/data/appConfig.json
     static_files: dist/assets/data/appConfig.json
     upload: dist/assets/data/appConfig.json
    
   - url: /two/(.*)
     static_files: dist/index.html
     upload: dist/index.html

Upvotes: 0

Views: 182

Answers (1)

JoX
JoX

Reputation: 140

Your dispatch rules mentions that you have to use either:

  • gcpdev.company.com/one/*
  • gcpdev.company.com/two/*

Then, is expected that calls to gcpdev.company.com/* fails. There isn´t any rule that dictates how to behave with that pattern.

About:

The correct one that opens the file is: https://gcpdev.company.com/one/vendor-es2017.65ff9b5300ddf6707a5c.js

It´s well worth to take a look into the Examples:

For instance:

dispatch:
  # Default service serves the typical web resources and all static resources.
  - url: "*/favicon.ico"
    service: default**strong text**

You might need to add something similar to the above mentioned, if you want to serve static files without /one/* and /two/* patterns.

About how to serve the static files on your services, checking Handlers element is the next step. My suggestion is to focus first in the dispatcher and as a second step the Handlers in the app.yaml.

Upvotes: 1

Related Questions