2018-07-11 22:02:07 +03:00
|
|
|
# These environment variables must be set in CircleCI UI
|
|
|
|
#
|
|
|
|
# DOCKERHUB_REPO - docker hub repo, format: <username>/<repo>
|
|
|
|
# DOCKER_USER - login info for docker hub
|
|
|
|
# DOCKER_PASS
|
|
|
|
#
|
|
|
|
|
|
|
|
version: 2
|
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
docker:
|
|
|
|
- image: circleci/node:8-jessie
|
|
|
|
steps:
|
|
|
|
- checkout
|
|
|
|
- setup_remote_docker
|
|
|
|
- run: ./bin/build
|
|
|
|
|
|
|
|
# save the built docker container into CircleCI's cache. This is
|
|
|
|
# required since Workflows do not have the same remote docker instance.
|
|
|
|
- run:
|
|
|
|
name: docker save app:build
|
|
|
|
command: mkdir -p /tmp; docker save -o /tmp/docker.tar "app:build"
|
|
|
|
- save_cache:
|
|
|
|
key: v1-{{ .Branch }}-{{epoch}}
|
|
|
|
paths:
|
|
|
|
- /tmp/docker.tar
|
|
|
|
- .env-dist
|
|
|
|
- Dockerfile
|
|
|
|
- docker-compose.yml
|
2019-04-03 00:48:28 +03:00
|
|
|
- docker-compose-ci.yml
|
2018-07-11 22:02:07 +03:00
|
|
|
test:
|
|
|
|
machine:
|
|
|
|
enable: true
|
|
|
|
environment:
|
|
|
|
DEVELOPMENT: 1
|
|
|
|
steps:
|
|
|
|
- checkout
|
|
|
|
- restore_cache:
|
2019-04-03 00:48:28 +03:00
|
|
|
key: v1-{{ .Branch }}
|
2018-07-11 22:02:07 +03:00
|
|
|
- run:
|
|
|
|
name: Restore Docker image cache
|
|
|
|
command: docker load -i /tmp/docker.tar
|
|
|
|
|
|
|
|
- run:
|
|
|
|
name: Install Docker Compose
|
|
|
|
command: |
|
2019-10-24 23:44:33 +03:00
|
|
|
curl -L https://github.com/docker/compose/releases/download/1.24.1/docker-compose-`uname -s`-`uname -m` > ~/docker-compose
|
2018-07-11 22:02:07 +03:00
|
|
|
chmod +x ~/docker-compose
|
|
|
|
sudo mv ~/docker-compose /usr/local/bin/docker-compose
|
|
|
|
|
|
|
|
- run:
|
|
|
|
name: Test Code
|
|
|
|
command: |
|
|
|
|
cp .env-dist .env
|
2019-02-07 00:24:26 +03:00
|
|
|
docker-compose -f docker-compose-ci.yml run -e DEVELOPMENT test-ci
|
2018-07-11 22:02:07 +03:00
|
|
|
|
|
|
|
deploy:
|
|
|
|
docker:
|
|
|
|
- image: docker:18.02.0-ce
|
|
|
|
steps:
|
2018-07-12 23:51:46 +03:00
|
|
|
- checkout
|
2018-07-11 22:02:07 +03:00
|
|
|
- setup_remote_docker
|
|
|
|
- restore_cache:
|
|
|
|
key: v1-{{.Branch}}
|
|
|
|
- run:
|
|
|
|
name: Restore Docker image cache
|
2018-07-12 23:05:13 +03:00
|
|
|
command: docker load -i /tmp/docker.tar
|
2018-07-11 22:02:07 +03:00
|
|
|
- run:
|
|
|
|
name: Deploy to Dockerhub
|
|
|
|
command: ./bin/deploy
|
|
|
|
|
|
|
|
workflows:
|
|
|
|
version: 2
|
|
|
|
build-test-deploy:
|
|
|
|
jobs:
|
|
|
|
- build:
|
|
|
|
filters:
|
|
|
|
tags:
|
|
|
|
only: /.*/
|
|
|
|
|
|
|
|
- test:
|
|
|
|
requires:
|
|
|
|
- build
|
|
|
|
filters:
|
|
|
|
tags:
|
|
|
|
only: /.*/
|
|
|
|
|
|
|
|
- deploy:
|
|
|
|
requires:
|
|
|
|
- build
|
|
|
|
- test
|
|
|
|
filters:
|
|
|
|
tags:
|
|
|
|
only: /.*/
|
|
|
|
branches:
|
|
|
|
only: master
|