Re: Problem loading symfony migrations post deploy after gcloud update container image in bitbucket pipelines

120 views
Skip to first unread message
Message has been deleted

Anthony Leo

unread,
Mar 26, 2021, 6:28:06 PM3/26/21
to gce-discussion
Hello, 

Thank you for the post. 

The Google Group forum is intended for discussion about GCE Products rather than troubleshooting specific issues. 

To get the most out of your interactions, we recommend you ask specific technical questions like "how do I…" or "what does this error mean?" on StackOverflow [1] or ServerFault [2] tagged with [google-cloud-platform] for more visibility. 

Furthermore, you may also see the main Community Support page [3] for a list of the tags we monitor. Please reference the Community Help Center on StackOverflow [1] and ServerFault [2] for information on how to ask a good question. 

[1]Stackoverflow:
[2]ServerFault:
[3]Community Support Page:



On Friday, March 26, 2021 at 12:38:13 PM UTC-4 ccas...@activosconcursales.com wrote:

I'm trying to setup a continuous deployment pipeline in bitbucket pipelines. The following is the pipelines code:

- export GCLOUD_API_KEY_FILE=~/.gcloud-api-key.json 
- echo $GOOGLE_CONTAINER_REGISTRY_KEY | base64 -d > $GCLOUD_API_KEY_FILE 
- gcloud auth activate-service-account --key-file $GCLOUD_API_KEY_FILE 
- gcloud auth configure-docker --quiet - export DOCKER_IMAGE_NAME=eu.gcr.io/project-name/image-name:$BITBUCKET_COMMIT 
- docker build -t $DOCKER_IMAGE_NAME -f docker/beta/Dockerfile . 
- docker push $DOCKER_IMAGE_NAME 
- gcloud config set project project-name 
- gcloud config set compute/zone europe-west3-a 
- gcloud compute instances update-container instance-name --container-image $DOCKER_IMAGE_NAME 
- /bin/bash ./scripts/deploy/beta/test.sh

In test.sh I check if the gcloud instance ssh is up, and if it is, I execute a post-deploy script:

test.sh

COUNTER=12 
POST_DEPLOY="docker exec klt-container-vgpx /application/scripts/deploy/beta/post-deploy.sh" 
 while [ $COUNTER -gt 0 ] 
do 
    gcloud compute ssh --verbosity=error --zone="europe-west3-a" "container-registry-and-compute@instance-name" --command="echo instance now up" 
    if [ $? -eq 0 ] 
    then 
        gcloud compute ssh container-registry-and-compute@instance-name --verbosity=info --command="$POST_DEPLOY" 
        exit 0 
     fi 
     sleep 10s 
     COUNTER=$((COUNTER-1)) 
done
 echo "ERROR: VM instance SSH service is not available" exit 1

post-deploy.sh

#!/bin/sh #Creates database, loads migrations and fixtures
 /application/bin/console doctrine:database:drop --if-exists --force --env=dev /application/bin/console doctrine:database:create --env=dev 
/application/bin/console doctrine:schema:create --env=dev 
/application/bin/console doctrine:migrations:migrate --no-interaction --env=dev --quiet /application/bin/console doctrine:fixtures:load --no-interaction --append --env=dev

The problem is that the migrations and fixtures are not being loaded. Bitbucket pipelines runs successfully but without executing all the commands of the script. It just creates the database and the schema.

If I launch the pipeline without the gcloud compute instances update-container command, the post-deploy.sh script executes successfully every single command.

Also works successfully if I add a 120s sleep after the gcloud compute instances update-container command, so I think that maybe all services are not loaded yet when the script is executed, but the problem then is, why is the database and the schema being created? I can see the following logs in bitbucket pipelines:

Dropped database `name-db` for connection named default 
Created database `name-db` for connection named default
 ! [CAUTION] This operation should not be executed in a production environment! Creating database schema...
Reply all
Reply to author
Forward
0 new messages