Skip to content

Deployment with Git

Maikel edited this page Oct 30, 2015 · 1 revision

Deploying a new version of OFN to a server can be as simple as this:

git push staging v1.0:master

The Setup

The provision playbook installs a Git post-receive hook on the server. That script deploys the last received version whenever you push code to that server. In order to push code to that server, you need a copy of it on your local machine.

git clone https://github.com/openfoodfoundation/openfoodnetwork.git
cd openfoodnetwork
# Change the username (ubuntu) and the domain name (staging.ofn.example.org)
# to the ones of your server.
git remote add staging [email protected]:apps/openfoodnetwork/current

Whenever you would like to deploy, fetch the latest updates and push the version you want to deploy:

git fetch
git push staging v1.2:master

For a staging server, you need the force switch if the new version is not an update of the current version (e.g. a downgrade):

git push staging v0.9:master --force

In that case, you probably want to reset the database before you push different code. There are two scripts in the OFN repository that might help you doing that:

  • script/ci/save_staging_baseline.sh
  • script/ci/load_staging_baseline.sh