Multiple services with different dockerfiles on GAE Flexible

后端 未结 3 1839
情话喂你
情话喂你 2020-12-11 10:56

I\'m using Google AppEngine Flexible with python environment. Right now I have two services: default and worker that share the same codebase, configured by app.yaml

3条回答
  •  天命终不由人
    2020-12-11 11:54

    Yes, as you mentioned, I think using the --image-url flag, is a good option here.

    Specify a custom runtime. Build the image locally, tag it, and push it to Google Container Registry (GCR) then, deploy your service, specifying a custom service file, and specifying the remote image on GCR using the --image-url option.

    Here's an example that accomplishes different entrypoints in 2 services that share the same code: ...this is assuming that the "flex" and not "standard" app engine offering is being used.

    lets say you have a: project called my-proj with a default service that is not important and a second service called queue-processor which is using much of the same code from the same directory. Create a separate dockerfile for it called QueueProcessorDockerfile and a separate app.yaml called queue-processor-app.yaml to tell google app engine what i want to happen.

    QueueProcessorDockerfile

    FROM node:10
    # Create app directory
    WORKDIR /usr/src/app
    COPY package.json ./
    COPY yarn.lock ./
    RUN npm install -g yarn
    RUN yarn
    # Bundle app source
    COPY . .
    CMD [ "yarn", "process-queue" ]
    

    *of course i have a "process-queue" script in my package.json queue-processor-app.yaml

    runtime: custom
    env: flex
    ... other stuff...
    ...
    
    1. build and tag the docker image Check out googles guide here -> https://cloud.google.com/container-registry/docs/pushing-and-pulling docker build -t eu.gcr.io/my-proj/queue-processor -f QueueProcessorDockerfile .
    2. push it to GCR docker push eu.gcr.io/my-proj/queue-processor
    3. deploy the service, specifying which yaml config file google should use, as well as the image url you have pushed gcloud app deploy queue-processor-app.yaml --image-url eu.gcr.io/my-proj/queue-processor

提交回复
热议问题