0

I am trying to use GCP app engine custom runtime flex to start an angular application.

My app.yaml

    service: web-ui
    runtime: custom
    env: flex

    manual_scaling:
    instances: 1
    resources:
    cpu: 2
    memory_gb: 2
    disk_size_gb: 20

My Dockerfile

    FROM node:10
    WORKDIR /usr/src/app
    COPY package*.json ./
    RUN npm install
    COPY . ./
    RUN npm install -g @angular/cli
    EXPOSE 8080
    RUN npm run build --prod
    COPY . ./
    CMD ["npm", "run", "start"]

Serve:

package.json - ng serve

angular.json

        "serve": {
            "builder": "@angular-devkit/build-angular:dev-server",
            "options": {
                "browserTarget": "ds-ng:build",
                "host": "0.0.0.0",
                "port": 8080

When trying to access the service - I get INVALID HOST HEADER.

Application is working fine when ssh to App engine instance where docker container runs.

I tried setting handler in app.yaml. But still see same problem. handlers: - url: /(.*) static_files: dist/index.html upload: dist/index.html

Waelmas
  • 1,894
  • 1
  • 9
  • 19
David
  • 1
  • I believe you're experiencing something similar to this [SO thread](https://stackoverflow.com/questions/43677629/invalid-host-header-when-running-angular-cli-development-server-c9-io) . Give the answers a try. – Waelmas Apr 27 '20 at 14:15
  • Also take a look at this [article](https://medium.com/@tiangolo/angular-in-docker-with-nginx-supporting-environments-built-with-multi-stage-docker-builds-bb9f1724e984) . It shows nice ways of dealing with angular apps in production when using Docker. The issue might be caused due to your Docker container not properly communicating with the outer world, this is why when you ssh to the instance it works. Also I have my doubts that setting the host to 0.0.0.0 is not proper for containerized angular apps in production. – Waelmas Apr 27 '20 at 14:21

0 Answers0