Skip to content

Instantly share code, notes, and snippets.

@webdeb
Created May 1, 2017 00:09
Show Gist options
  • Save webdeb/2a8209304964a621184bdb6eadbc9765 to your computer and use it in GitHub Desktop.
Save webdeb/2a8209304964a621184bdb6eadbc9765 to your computer and use it in GitHub Desktop.
DinD pipeline to build & test phoenix applications
image: docker:latest
variables:
PWD: $(pwd)
BUILD_BOX: webdeb/phx-dev
DATA_BOX: build_data_$CI_PROJECT_ID_$CI_BUILD_REF
stages:
- build
- test
- cleanup
build:
stage: build
before_script:
- docker create --name $DATA_BOX -v /opt/app busybox
- docker cp . $DATA_BOX:/opt/app
script:
- docker run --rm -t --volumes-from $DATA_BOX
$BUILD_BOX
sh -c "yarn && mix do deps.get, deps.compile"
test:
stage: test
variables:
DATABASE_URL: ecto://postgres:postgres@postgres/karta_test
services:
- postgres:9.6
script:
- docker run --rm -t
--volumes-from build-data
--link $POSTGRES_NAME:postgres
-e DATABASE_URL=$DATABASE_URL
$BUILD_BOX
sh -c "mix ecto.create && mix ecto.migrate && mix test"
# Always cleaning up
cleanup_job:
tags:
- docker
stage: cleanup
script:
- docker rm $DATA_BOX
when: always
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment