compudeploy
creates, deploys and updates CiviCRM websites
- The creation command should take a single repository URL
- The host for the site should be flexible: local host, local vagrant, local docker, remote host, AWS
- The type of site should be flexible: a profile or a "full site" repository
Adds a server configuration for deployment
compubuild add-server --type=remote --name=testing1 --target=<target>
name
: The name of the configurationtype
: What kind of server is it. For example jenkins, remote, aws, local or dockertarget
: Not required for all types, but if a server is remote points to where it is located
Creates a new site
compubuild create --repo=http://bitbucket.org/compucorp/mysite \
--build-dir=/var/www/mysite \
--url=mysite.civihr.net \
--server=testing1 \
--name=testing1 \
--git-ref=CGP-my-feature-branch \
--git-merge-ref=CGP-my-workstream-branch \
--cms-db=./dumps/drupal-test.sql \
--civi-db=./dumps/civi-test.sql
name
: The name of the siteserver
: Which server it should be deployed tourl
: The URL for the sitebuild-dir
: Where on the server the site should be createdrepo
: What repository to use to create the sitegit-ref
: Optional branch of the repository to check out before buildinggit-merge
: Optional branch to merge intogit-ref
before buildingcms-db
: Allows import of a certain database before running upgraders for Drupal. Supports local and remote filescivi-db
: Allows import of a certain database before running upgraders for CiviCRM. Supports local and remote files
Deploys code changes to an existing site
compubuild deploy
--name=testing1 \
--git-ref=CGP-my-feature-branch \
--git-merge-ref=CGP-my-workstream-branch
--skip-upgraders \
--cms-db=scp://123.23.234.42/dumps/drupal.mysql \
--civi-db=scp://123.23.234.42/dumps/civicrm.mysql
name
: The name of the sitegit-ref
: Optional branch of the repository to check outgit-merge
: Optional branch to merge intogit-ref
skip-upgraders
: Whether to run the Drupal and CiviCRM upgraders during deploymentcms-db
: Allows import of a certain database before running upgraders for Drupal. Supports local and remote filescivi-db
: Allows import of a certain database before running upgraders for CiviCRM. Supports local and remote files
Destroy all resources related to a site: db, files, vhosts
compubuild destroy --name=mysite
name
: The name of the site to destroy
Takes a snapshot of the database
compubuild snapshot --name=mysite --snapshot-name=pre-release
name
: the name of the sitesnapshot-name
: the name to store the snapshot as, defaults to "default"
Restores the databases using a snapshot name or defaults to "default" if none provided
compubuild restore --name=mysite --snapshot-name=pre-release
name
: the name of the sitesnapshot-name
: the name to store the snapshot as, defaults to "default"
Executes a command on a site and returns the result
compubuild exec --name=mysite --dir=profiles/compuclient --cmd=phpunit4
name
: The name of the sitedir
: The directory from where the command should be executedcmd
: The command to run
add-server --type=local --name=local
create --repo=http://bitbucket.org/compucorp/mysite \
--build-dir=/home/michael/sites/mysite \
--url=mysite.local \
--server=local \
--name=local-mysite
add-server --type=vagrant --name=vagrant1
create --repo=http://bitbucket.org/compucorp/mysite \
--build-dir=/home/michael/sites/mysite \
--url=mysite.local \
--server=vagrant1 \
--name=local-mysite
add-server --type=remote --name=testing1 --target=184.112.23.23
create --repo=http://bitbucket.org/compucorp/mysite \
--build-dir=/var/www/mysite \
--url=mysite.civihr.net \
--server=testing1 \
--name=testing1
add-server --type=remote --name=testing1 --target=184.112.23.23
create --repo=http://bitbucket.org/compucorp/mysite \
--build-dir=/var/www/mysite \
--url=mysite.civihr.net \
--server=testing1 \
--git-ref=CGP-my-new-branch \
--name=pr221
add-server --type=remote --name=testing1 --target=184.112.23.23
create --repo=http://bitbucket.org/compucorp/mysite \
--build-dir=/var/www/mysite \
--url=mysite.civihr.net \
--server=testing1 \
--git-ref=CGP-my-new-branch \
--name=pr221
exec --dir=/var/www/mysite/profiles/compuclient phpunit4
add-server --type=aws --name=aws1
create --repo=http://bitbucket.org/compucorp/mysite \
--build-dir=/var/www/mysite \
--url=mysite.civihr.net \
--server=aws1
add-server --type=remote --name=mysite --target=184.112.23.23
create --repo=http://bitbucket.org/compucorp/mysite \
--build-dir=/var/www/mysite \
--url=mysite.civihr.net \
--server=mysite
add-server --type=remote --name=mysite --target=184.112.23.23
create --repo=http://bitbucket.org/compucorp/mysite \
--build-dir=/var/www/mysite \
--url=mysite.civihr.net \
--server=mysite
--name=mysite
deploy --name=mysite --git-ref=1.1.0
add-server --type=remote --name=mysite --target=184.112.23.23
create --repo=http://bitbucket.org/compucorp/mysite \
--build-dir=/var/www/mysite \
--url=mysite.civihr.net \
--name=mysite \
--server=mysite \
--git-ref=1.0.0
snapshot --name=mysite --name=pre-relase
deploy --name=mysite --git-ref=1.1.0 #returns failure
restore --name=mysite --name=pre-release
deploy --name=mysite --git-ref=1.0.0
add-server --type=remote --name=mysite --target=184.112.23.23
create --repo=http://bitbucket.org/compucorp/mysite \
--build-dir=/var/www/mysite \
--url=mysite.civihr.net \
--server=testing1 \
--git-ref=CGP-my-new-branch \
--name=pr221 \
--cms-db=./../dumps/brochure_drupal.mysql \
--civi-db=./../dumps/brochure_civicrm.mysql
add-server --type=remote --name=dev1 --type=aws
create --repo=http://bitbucket.org/compucorp/mysite \
--build-dir=/var/www/mysite \
--server=testing1 \
--git-ref=CGP-my-new-branch \
--name=pr221 \
--cms-db=scp://123.23.234.42/dumps/drupal.mysql \
--civi-db=scp://123.23.234.42/dumps/civicrm.mysql
add-server --type=remote --name=mysite --target=184.112.23.23
create --repo=http://bitbucket.org/compucorp/mysite \
--build-dir=/var/www/mysite \
--url=mysite.civihr.net \
--server=testing1 \
--git-ref=CGP-my-new-branch \
--name=pr221
destroy pr221
- [] create brochure-site from master in Vagrant
- [] create brochure-site from master in Docker-
- [] create profile site from compuclient master in Vagrant
- [] create brochure-site and use imported db dumps
- [] create brochure-site based of different branch
- [] create brochure-site with different branch and merge staging
- [] create profile site in remote host
@davialexandre
For local sites nothing happens, for vagrant or remote sites it just stores configuration for where a server is located. For AWS or other cloud providers I thought it could be an option to spin up a new instance using their API. In this way we would have the option to create new instances on the fly when a PR came in and destroy them after a PR is merged.
I think (based on your comment below about "we'll always use it on the server where the site will run") that maybe you're thinking this is a direct replacement for civibuild. I'd like it to be more than that; a tool to allow you to clone a client site locally and set it up using a database dump, allow you to deploy to multiple servers, potentially orchestrating deployments to all client sites, and also accept requests from webhooks to automatically deploy a certain branch for a client.
Maybe some of them are too much, I'll probably remove Docker for now but originally added it because I wanted to test this with Docker first. I REALLY don't want to install all the shitty old versions of MySQL, PHP and all the other junk I need to get D7 + CiviCRM running on my host machine so I created a Dockerfile with all the libraries I needed and mounted the tool inside it, using the docker container as my "local"
Sure I can do that, although I'm not sure if just
ref
is enough information to go on. Originally I would have thoughtbranch
would be fine, but I wanted something to show the user that any git reference (branch / commit hash / tag) is fine. Any suggestions?I was planning to always merge staging in but it might be better to change this to make it more configurable. I would like to keep this as flexible as possible to cater for all workflow. Do you think making the merge reference a comma separated list would be an option? Something like
--git-ref=CGP-111-myfeature --merge-refs=staging,CGP-120-myworkstream
?Exactly, I'm just thinking of when we actually need to test upgraders for CiviHR how we need to do a manual deployment. I thought it would be nice if we added an option to not run the upgraders and also make it configurable whether we want to reset using a snapshot or not.
I haven't used tarballs much, I know sometimes they're used to reduce the code in production but if we are going to always use them do you think you could give me a bit more information on why we need to support them? From my (basic) understanding it seems cleaner to just use git to checkout code. I checked a few articles, seems to be no clear consensus on which is better, but I'm happy to add support for tarball deployment instead of git.