TODO: build -> version only in test
make latest
make release
Example: Gitlab CI
- build
- test
- report
- deploy
- cleanup
Example trigger for stacks-staging
deploy:latest:
stage: deploy
script:
- curl -X POST -F token=${PROJECT_TOKEN} -F ref=${PROJECT_REF} -F "variables[REDEPLOY_STACK_DIR]=${STACK_DIR}" https://git.hrzg.de/api/v3/projects/256/trigger/builds
only:
- latest
Variables:
PROJECT_TOKEN
- token fromstacks-staging
projectPROJECT_REF
- branch, usuallymaster
PROJECT_DIR
- location ofdocker-compose.yml
, eg.auto/cusomter/www.example.com
Set Variables
PHP_IMAGE_NAME
registry.example.com/namespace/project_phpGITHUB_API_TOKEN
abcd1234
- Clone application from local repository
- Start application
make all
- Make changes in local development stack
- (optional) Run tests in isolated local testing stack
make TEST up setup run-tests
- Commit (triggers CI)
- CI builds images
- CI starts isolated stacks (by setting custom
COMPOSE_PROJECT_NAME
s) from built images and performs setup operations - CI runs tests (also acceptance tests with Selenium containers)
- CI creates reports
- CI performs cleanup of isolated stacks
- CI tags images and pushes them to a registry (if tests were successful)
Run the test suites from build scripts
$ sh build/scripts/build.sh
$ sh build/scripts/test.sh
Adjust your Dockerfile
and build FROM phundament/app:production
.
make build
Push example
after_success: |
docker login -u="$REGISTRY_USER" -p="$REGISTRY_PASS" $REGISTRY_HOST
if [ "${TRAVIS_BRANCH}" = "release" ]; then
docker tag ${STACK_PHP_IMAGE} ${STACK_PHP_IMAGE_LATEST}
docker-compose push || exit 1
docker push ${STACK_PHP_IMAGE_LATEST} || exit 1
fi
docker logout
- All images MUST BE tagged
Push to branch foo
results in Docker image appsrc:foo
.