As a developer, the most convenient deployment method is a git push
deployment.
The workflow looks like this:
- You have deployment branches such as
production
orstaging
in your source code repository. - Each time you push to a deployment branch, a Continuous Integration (CI) pipeline will deploy your code to the respective environment.
Included is a template with customization instructions which you may use to set this workflow up on Bitbucket, using Bitbucket Pipelines as your CI platform.
- The guide assumes you have already created a Stage on SetOps.
- There is a SetOps service account which can access the stage. See also Service Account Setup.
- You have set up Repository Variables for the SetOps service account credentials, and they are named
SETOPS_USER
andSETOPS_PASSWORD
.
This template is made for a web application with three apps (web
, job
, clock
). Each of these apps run the same source Docker image.
-
Merge the template with your existing Bitbucket Pipelines configuration in
/bitbucket-pipelines.yml
.If you do not have one yet, you can copy the template as-is.
-
Review the template.
In particular:
- The deployment should run at the end of existing jobs (unit tests, for example), and it should declare a dependency on previous jobs.
- The workflow includes two ways of building a Docker image: the classic
Dockerfile
way and Cloud Native Buildpacks. Visit the guide on Docker images in the SetOps documentation to learn about both alternatives. - Add the
run_deploy_tasks
script in the/bin/
directory, in case you want to run something for each deployment (e.g. database migrations). For the script to run the tasks, you need to set theDEPLOY_TASKS
ENV to a semicolon-separated list of commands. For example:DEPLOY_TASKS=rails db:migrate;echo \"HI\"
. - If your apps are not called
web
,worker
, andclock
, you need to adjust the names and add/remove the respective steps. - If your deployment branches differ from
staging
orproduction
, you need to adjust the names. - If you did not configure a Container Healthcheck, replace
HEALTHY
withRUNNING
in theWait for $NAME task to be healthy
steps.
-
Commit the configuration, push to a deployment branch, and enjoy automatic deployments.
You need a SetOps service account to deploy your application. This is required for the pipeline to run successfully.
- Ask your SetOps admins for user creation and name your project repository
- The SetOps admins will create the SetOps user and share the credentials
- The credentials must be stored in Bitbucket as repository variables (
SETOPS_USER
andSETOPS_PASSWORD
) - The SetOps admins will tell you the email of the user, you need to authorize it to your stage via
setops --stage <STAGE> user invite [email protected]