funder7
funder7

Reputation: 1845

Passing arguments to Docker build while deploying AppEngine flex

I'm wondering if it's possible to feed arguments, or environment variables into a Dockerfile used by AppEngine (flex environment).

I'd like to use this command:

COPY ${STAGE}/keycloak-files/realm-config/* /opt/jboss/keycloak/realm-config/

"STAGE" variable would allow to select the origin (I have a "staging" and "production" directory, containing different configurations).

I've got two different app.yml files, one for each environment, but from what I read online, environment variables are not exposed to the Dockerfile at build time.

People suggest to pass arguments to accomplish the task. But how would that be possible with appengine, where we don't execute the docker build command directly?

Upvotes: 2

Views: 758

Answers (1)

drauedo
drauedo

Reputation: 696

As @DamPlz said there is not a straight way to pass env variables from the app.yaml to the Dockerfile during the deployment phase . Here are some workarounds that I could think of:

  1. One option could be to create the variable in the Dockerfile directly and if you want to change it each time at runtime you can use a placeholder value and have a script update the value of the variable before running “gcloud app deploy”.
  2. On the other hand you could use build triggers in Google Cloud Registry to modify it in the Docker image using user-defined substitutions.

Upvotes: 2

Related Questions