I’m using CircleCI to build a docker image and push it to docker hub. I’m making use of the docker orb.
orbs:
docker: circleci/docker@0.5.13
It’s all working fine except that in order to publish both with a hash and with the latest tag i’m building the container twice. Any tips on how I can remove the duplicated effort?
my config.yml looks like:
version: 2.1
orbs:
docker: circleci/docker@0.5.13
jobs:
run_tests:
docker:
- image: circleci/node:10.16.3
steps:
- checkout
- run:
name: update-npm
command: 'sudo npm install -g npm@latest'
working_directory: frontend
- restore_cache:
key: dependency-cache-{{ checksum "frontend/package.json" }}
- run:
name: npm-install
command: npm install
working_directory: frontend
- save_cache:
key: dependency-cache-{{ checksum "frontend/package.json" }}
paths:
- ./node_modules
- run:
name: test
command: npm test
working_directory: frontend
workflows:
version: 2
build_deploy:
jobs:
- run_tests
- docker/publish:
image: myrepo/typeit-frontend
requires:
- run_tests
filters:
branches:
only:
- master
- docker/publish:
image: myrepo/typeit-frontend
tag: latest
requires:
- run_tests
filters:
branches:
only:
- master