简体   繁体   中英

deploying to app engine flex custom runtime with cloud build causes a large amount of builds to run

i am Kinda new to cloud build so i am kind of confused about what is happening.

first this is my file structure

cloudbuild.yaml
    backend/
           Dockerfile
           app.yaml

I had an application which i dockerized and deployed to app engine felx in custom runtime

here's my Dockerfile

FROM mcr.microsoft.com/dotnet/sdk:5.0-buster-slim AS build
WORKDIR /app

# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore
COPY . ./
RUN dotnet publish -c Release -o out

FROM mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim AS base 
ENV ASPNETCORE_URLS=http://+:80;

WORKDIR /app
COPY --from=build /app/out .
EXPOSE 80
ENTRYPOINT ["dotnet", "myapp.dll"]

and this is my app engine flex file

runtime: custom
env: flex
manual_scaling:
  instances: 1
resources:
  cpu: 1
  memory_gb: 0.5
  disk_size_gb: 10
service: backend
network:
  name: my-network
  subnetwork_name: my-network-subnet
  instance_tag: "backend"
  forwarded_ports:

I have successfully deployed this app on app engine flex using this command

gcloud app deploy --appyaml=app.yaml

Then i added a cloudbuild.yaml file following this google doc

steps:
  - name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
    entrypoint: 'bash'
    args: ['-c', 'gcloud config set app/cloud_build_timeout 2000 && gcloud app deploy --appyaml=backend/app.yaml']

as you can see in the cloudbuild.yaml i didnt add the timeout attribute because it gave me this error each time i tried to submit the build.

Error Response: [13] Error parsing cloudbuild.yaml for runtime custom: Argument is not an object: "2000s"

after removing the timeout attribute, cloud build started behaving in a weird way, it kept creating build jobs on its own until it reached over 20 builds. i had to stop these builds manually because it exceeded the 120 minute free quota limit.

can some one tell me if my cloudbuild.yaml is the thing causing the issue or if its a problem with google cloud.

So the problem was writing the cloudbuild as a yaml file, instead i re-wrote it as a json file, i am not entirely sure why is the cloudbuild.yaml file was giving me errors but that was my solution.

{
    "steps": [
    {
      "name": "gcr.io/google.com/cloudsdktool/cloud-sdk",
      "entrypoint": "bash",
      "args": [
        "-c",
        "gcloud config set app/cloud_build_timeout 1600 && gcloud app deploy --appyaml=app.yaml"
       ]
    }
    ],
    "timeout": "1600s"
  }

Also the cloudbuild and app.yaml must be in the root of the branch with the cloudbuild file and Dockerfile.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM