Demo of using Convox on CircleCI: https://circleci.com/gh/jordansexton/convox-circle
Originally inspired by Continuous Deployment with CircleCI and Convox.
This demo project is a set of shell scripts and CircleCI configuration that enables running convox start
as a background process on CircleCI, and executing tests inside the app
Docker container it brings up.
This is useful for allowing your test environment to closely model your deployment environment. The demo tests a simple Node HTTP server with linked Postgres and Redis containers.
- This requires CircleCI's Ubuntu 14.04 environment for Docker 1.9 support which is required by Convox. Set this at
https://circleci.com/gh/<GITHUB_ORG>/<GITHUB_REPO>/edit#build-environment
- The environment may have MongoDB, MySQL, PostgreSQL, and/or Redis running.
stop-services.sh
is run to kill them because of port conflicts. - CircleCI has a special convention for background processes.
start.sh
is run in the background in this fashion, andwait-for-start.sh
echos its output until theapp
Docker container is up. docker exec
doesn't work on CircleCI.lint.sh
andtest.sh
have to uselxc-attach
to run in theapp
Docker container.- Since environment variables don't seem to be preserved by
lxc-attach
in the same way asdocker exec
,export-docker-env.sh
is used to pull them into the Docker host's environment so they can be propagated. - There is also
deploy.sh
for automating the deployment after your tests pass based on @matthewford's article. This is configured to only run on thedeploy
branch. circle.yml
is configured to export the logs for all meaningful steps as artifacts.
This involved some shell scripting and some manipulation of Docker containers and I'm not very good at either.
There are probably smarter, more performant, and more idiomatic ways to do everything I'm doing.
Please tell me what they are or submit a pull request!
git clone https://github.com/jordansexton/convox-circle.git
cd convox-circle
cp .env.example .env
chmod +x convox-test.sh
./convox-test.sh
- Go to https://console.convox.com/grid/user/profile
- Copy your Convox account API key
- Go to
https://circleci.com/gh/<GITHUB_ORG>/<GITHUB_REPO>/edit#env-vars
- Create some environment variables:
-
CONVOX_APP=<YOUR CONVOX APP NAME>
(e.g.api
) -CONVOX_ORG=<YOUR CONVOX ORG NAME>
(e.g.acme
) -CONVOX_PASSWORD=<YOUR CONVOX API KEY>
(e.g.45f2cb79-a941-4758-ab53-056574d75216
) -CONVOX_RACK=<YOUR CONVOX RACK NAME>
(e.g.production
)