appengine-ruby icon indicating copy to clipboard operation
appengine-ruby copied to clipboard

Specify project via environment variable

Open RSpace opened this issue 7 years ago • 2 comments

I deploy into multiple GCloud projects, and would like to be able to specify the project id via an environment variable when calling rake appengine:exec, similar to how ie. GAE_SERVICE can be specified.

As far as I can see from the source code, this is not currently possible?

RSpace avatar Nov 30 '18 10:11 RSpace

Yeah, I am running into the same issue. I've found an ugly way to get around it I am SSH'ing to an active instance/container and running within the docker container:

  1. SSH to the server running your container:
gcloud --project $PROJECT_NAME app instances ssh $(gcloud app instances list --service=$SERVICE_NAME --filter=VM_STATUS:RUNNING --format=json | jq -r '.[0].id') --version $(gcloud app instances list --service=$SERVICE_NAME --filter=VM_STATUS:RUNNING --format=json | jq -r '.[0].version') --service=$SERVICE_NAME
  1. Run your command against the container:
docker exec -it gaeapp /bin/bash -c "$YOUR_CMD"
# Examle
docker exec -it gaeapp /bin/bash -c "bundle exec rake db:migrate"
# Or, just shell into the container to run whatever you'd like within the environment:
docker exec -it gaeapp /bin/bash

Note, if you get an unknown container error using gaeapp in the second step, run sudo docker ps find the name of the correct container and replace gaeapp in the previous command.

Based on: https://gist.github.com/kyptin/e5da270a54abafac2fbfcd9b52cafb61

Alternatively: You can just swap what project you are configured, but this seems like a good way to make a mistake lol

gcloud config set project $TARGET_PROJECT_NAME
bundle exec rake appengine:exec[...]

will3216 avatar Feb 20 '19 23:02 will3216

Version 0.5 (coming within a week or so) will include the ability to set GAE_PROJECT.

dazuma avatar Jul 09 '19 00:07 dazuma