sudo: required
language: c
services:
  - docker

script:
# Lint
- docker run -it --rm -v "$PWD/Dockerfile:/Dockerfile:ro" redcoolbeans/dockerlint
- docker run -it --rm -v "$PWD/Dockerfile.onbuild:/Dockerfile:ro" redcoolbeans/dockerlint

env:
  global:
    - COMMIT=${TRAVIS_COMMIT::8}

after_success:
# Setup
  - export REPO=gatsbyjs/gatsby
  - export MAIN_TAG=`if [ "$TRAVIS_BRANCH" = "master" ]; then echo "latest"; else echo $TRAVIS_BRANCH ; fi`
  - export ONBUILD_TAG=`if [ "$TRAVIS_BRANCH" = "master" ]; then echo "onbuild"; else echo "$MAIN_TAG-onbuild" ; fi`
  - echo "Main tag - $MAIN_TAG | Onbuild - $ONBUILD_TAG | Commit (shorten) - $COMMIT | Branch - $TRAVIS_BRANCH"
  - docker login -u $DOCKER_USER -p $DOCKER_PASS

# Build and deploy
  - docker build -f Dockerfile -t $REPO:$COMMIT .
  - docker build -f Dockerfile.onbuild -t $REPO:$COMMIT-onbuild .
  - docker tag $REPO:$COMMIT $REPO:$MAIN_TAG
  - docker tag $REPO:$COMMIT-onbuild $REPO:$ONBUILD_TAG

  - docker push $REPO

sudo: required
language: c
services:
  - docker

script:
# Lint
- docker run -it --rm -v "$PWD/Dockerfile:/Dockerfile:ro" redcoolbeans/dockerlint
- docker run -it --rm -v "$PWD/Dockerfile.onbuild:/Dockerfile:ro" redcoolbeans/dockerlint

env:
  global:
    - COMMIT=${TRAVIS_COMMIT::8}

after_success:
# Setup
  - export REPO=gatsbyjs/gatsby
  - export MAIN_TAG=`if [ "$TRAVIS_BRANCH" = "master" ]; then echo "latest"; else echo $TRAVIS_BRANCH ; fi`
  - export ONBUILD_TAG=`if [ "$TRAVIS_BRANCH" = "master" ]; then echo "onbuild"; else echo "$MAIN_TAG-onbuild" ; fi`
  - echo "Main tag - $MAIN_TAG | Onbuild - $ONBUILD_TAG | Commit (shorten) - $COMMIT | Branch - $TRAVIS_BRANCH"
  - 
  - docker login -u $DOCKER_USER -p $DOCKER_PASS

# Build and deploy
  - docker build -f Dockerfile -t $REPO:$COMMIT .
  - cat Dockerfile.onbuild | sed "s/gatsbyjs/gatsby:latest/$REPO:$COMMIT/" | docker build -t $REPO:$COMMIT-onbuild -
  - docker tag $REPO:$COMMIT $REPO:$MAIN_TAG
  - docker tag $REPO:$COMMIT-onbuild $REPO:$ONBUILD_TAG

  - docker push $REPO

Build the onbuild tag based on the image built before
Build the onbuild tag based on the image built before