Skip to content

Commit

Permalink
Save images in CircleCI workspace instead of quay.io
Browse files Browse the repository at this point in the history
  • Loading branch information
bboreham committed Jul 29, 2018
1 parent 2e7196d commit 1bba580
Showing 1 changed file with 18 additions and 32 deletions.
50 changes: 18 additions & 32 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,15 @@ jobs:
exit 1
fi
- run:
name: Upload docker images for use later in workflow
name: Save docker images for use later in workflow
command: |
docker login -u "$DOCKER_REGISTRY_USER" -p "$DOCKER_REGISTRY_PASSWORD" quay.io
IMAGE_TAG="$(./tools/image-tag)"
IMAGES=$(make images)
for image in ${IMAGES}; do
if [[ "$image" == *"build"* ]]; then
continue
fi
tagged_image="${image}:${IMAGE_TAG}"
repo_tmp_image="$(echo $tagged_image | sed -E 's|(/weaveworks)/(.*):(.*)|\1/build-tmp:\2-\3|')"
docker tag ${tagged_image} ${repo_tmp_image}
docker push $repo_tmp_image
done
IMAGES=$(for image in $(make images); do echo $image; done | grep -v build)
docker save $IMAGES > saved-images
- persist_to_workspace:
root: .
paths:
- saved-images

test:
<<: *defaults
steps:
Expand All @@ -65,25 +60,12 @@ jobs:
<<: *defaults
steps:
- checkout
- &pull-tmp-images
- attach_workspace:
at: .
run:
name: Download docker images build earlier in workflow
name: Load docker images built earlier in workflow
command: |
docker login -u "$DOCKER_REGISTRY_USER" -p "$DOCKER_REGISTRY_PASSWORD" quay.io
# Pull our previously built image, retag it
IMAGE_TAG="$(./tools/image-tag)"
IMAGES=$(make images)
for image in ${IMAGES}; do
if [[ "$image" == *"build"* ]]; then
continue
fi
tagged_image="${image}:${IMAGE_TAG}"
repo_tmp_image="$(echo $tagged_image | sed -E 's|(/weaveworks)/(.*):(.*)|\1/build-tmp:\2-\3|')"
docker pull $repo_tmp_image
docker tag ${repo_tmp_image} ${tagged_image}
docker tag ${repo_tmp_image} ${image}:latest
docker image rm ${repo_tmp_image}
done
docker load saved-images
make touch-uptodate
# FIXME: we probably don't need to copy the code and change the working dir
- run: echo -e "export GOPATH=$HOME\nexport SRCDIR=$HOME/src/github.com/weaveworks/service\nexport PATH=/usr/local/go/bin:$HOME/bin:$PATH" >> $BASH_ENV
Expand All @@ -109,7 +91,9 @@ jobs:
<<: *defaults
steps:
- checkout
- <<: *pull-tmp-images
- attach_workspace:
at: .
- run: docker load saved-images
- run:
name: Publish docker images to final repository
command: |
Expand All @@ -122,7 +106,9 @@ jobs:
<<: *defaults
steps:
- checkout
- <<: *pull-tmp-images
- attach_workspace:
at: .
- run: docker load saved-images
- run:
name: Dry-run of publishing docker images
command: |
Expand Down

0 comments on commit 1bba580

Please sign in to comment.