You will need roughly 3 minutes to read this article.
To deploy to Google App Engine, you will need to create a container that can authenticate with your Google Account, and with the appropriate Google product, as well as run the Google Cloud CLI to execute your intended commands.
We maintain an example repository with an image stored on Docker Hub to simplify this process. You can copy setup instructions from this repo or reuse the Dockerfile, our turnkey Google Cloud image or our GCR authentication generator simply by adding the necessary elements from our Google Cloud repo to your codeship-services.yml file.
To deploy to App Engine, you will need to define a Google Service account as well as add your Google credentials to your encrypted environment variables so that the
gcloud utility can authenticate appropriately.
For full instructions, see the authentication portion of our Google Cloud documentation.
Some Google Cloud services will require that you add your CodeShip public key for authentication purposes.
Note that Google may fail authentication if you do not add the Google Cloud user the key is for to the end of the key. For example, if the Google Cloud user is
deploy@CodeShip, you will want to add
deploy@CodeShip to the end of the SSH key itself, otherwise Google will not load the key for the user appropriately.
googleclouddeployment: image: codeship/google-cloud-deployment encrypted_env_file: - google-credentials.encrypted add_docker: true volumes: - ./:/deploy
Note that this example adds your Google Cloud account credentials as encrypted environment variables and mounts the repository as a volume to the
/deploy folder inside the container so that it is usable as part of the build.
After defining your authentication variables and your deployment service, you will want to run deployment commands via your codeship-steps.yml file.
Because each step runs in a separate group of containers, you will likely want to bundle you Google Cloud commands together in a script file that you add to your repository and call from a step:
- name: google-cloud-deployment service: googleclouddeployment command: google-deploy.sh
Inside this deployment script will be all commands you want to run via the Google Cloud or Kubernetes CLI, both included in the [deployment image that we maintain]((https://hub.docker.com/r/codeship/google-cloud-deployment/).
Here is an example deployment script that you can use as a basis for your own deployments. Note that it authenticates at the top using the command discussed earlier.
#!/bin/bash # Authenticate with the Google Services codeship_google authenticate # switch to the directory containing your app.yml (or similar) configuration file # note that your repository is mounted as a volume to the /deploy directory cd /deploy/ # deploy the application gcloud app deploy --quiet
Please see the documentation for
gcloud app deploy on which more options are available and how they affect the deployment.
Google also publishes stack and language specific tutorials for deploying to App Engine via their documentation, detailing more advanced options. See their App Engine documentation for specific articles on deploying Ruby, Node.js or PHP based applications (among others).
Contact our support team or post on Stack Overflow using the tag
#codeship. Did you check the status page and changelog?
There are also several code examples and sample projects available for you to get started with.