Skip to content

Commit

Permalink
Build docker images during publish (#336)
Browse files Browse the repository at this point in the history
When building and publishing a docker image in multiple jobs, only the architecture of the CI runtime is persisted. We want to build and publish all architectures, so we've reverted to building the docker image as part publish step.

Co-authored-by: JamieDanielson <[email protected]>
  • Loading branch information
MikeGoldsmith and JamieDanielson authored Oct 13, 2021
1 parent e9b91f1 commit 0f24ad0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 22 deletions.
29 changes: 14 additions & 15 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,26 +129,22 @@ jobs:
- run: go install github.com/google/ko@latest
- checkout
- setup_remote_docker
- run: ./build-docker.sh
- run: mkdir -p ~/images
- run: docker save honeycombio/refinery | gzip > ~/images/refinery.tar.gz
- persist_to_workspace:
root: ~/
paths:
- images
- store_artifacts:
path: ~/images
- run:
name: build docker images and publish locally
command: ./build-docker.sh

publish_docker:
docker:
- image: cimg/base:stable
- image: cimg/go:1.16
steps:
- attach_workspace:
at: ~/
- run: go install github.com/google/ko@latest
- checkout
- setup_remote_docker
- run: docker load -i ~/images/refinery.tar.gz
- run: echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin;
- run: docker image push -a honeycombio/refinery
- run:
name: build docker images and publish to Docker Hub
environment:
KO_DOCKER_REPO: honeycombio
command: ./build-docker.sh

workflows:
build:
Expand All @@ -173,6 +169,7 @@ workflows:
context: Honeycomb Secrets for Public Repos
requires:
- build_binaries
- build_docker
filters:
tags:
only: /^v.*/
Expand All @@ -182,6 +179,7 @@ workflows:
context: Honeycomb Secrets for Public Repos
requires:
- build_binaries
- build_docker
filters:
tags:
only: /^v.*/
Expand All @@ -190,6 +188,7 @@ workflows:
- publish_docker:
context: Honeycomb Secrets for Public Repos
requires:
- build_binaries
- build_docker
filters:
tags:
Expand Down
8 changes: 1 addition & 7 deletions build-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fi

unset GOOS
unset GOARCH
export KO_DOCKER_REPO="ko.local"
export KO_DOCKER_REPO=${KO_DOCKER_REPO:-ko.local}
export GOFLAGS="-ldflags=-X=main.BuildID=$VERSION"
export SOURCE_DATE_EPOCH=$(date +%s)
# shellcheck disable=SC2086
Expand All @@ -22,9 +22,3 @@ ko publish \
--base-import-paths \
--platform "linux/amd64,linux/arm64" \
./cmd/refinery

# update tags to use correct org name
for TAG in ${TAGS//,/ }
do
docker image tag ko.local/refinery honeycombio/refinery:$TAG
done

0 comments on commit 0f24ad0

Please sign in to comment.