How to force Travis to fail if docker build fails

I’m having CI/CD with Travis which push 3 docker images and then deploys to AWS Elastic Beanstalk. Sometimes it happens that building of one of the docker images fails which doesn’t cause Travis to fail, so other 2 docker containers are pushed and AWS script is pushed causing my AWS EB multi-docker environment to run with not-compatible docker images.

Is it possible to somehow force Travis to fail and stop further actions in case of such failure?

My Travis script looks like this:

after_success:
  - docker build -t jeremycod/fillrx-client ./client
  - docker build -t jeremycod/fillrx-nginx ./nginx
  - docker build -t jeremycod/fillrx-api ./server
  # Log in to the docker CLI
  - echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_ID" --password-stdin

  # Take those images and push them to docker hub
  - docker push jeremycod/fillrx-client
  - docker push jeremycod/fillrx-nginx
  - docker push jeremycod/fillrx-api

deploy:
  provider: elasticbeanstalk
  region: 'ca-central-1'
  app: 'myapp'
  env: 'myapp-env'
  bucket_name: 'elasticbeanstalk-ca-central-1-xxxxx11111'
  bucket_path: 'assets'
  on:
    branch: master
  access_key_id: $AWS_ACCESS_KEY
  secret_access_key: $AWS_SECRET_KEY

Source: Docker Questions