Skip to content

QUA-958: Push images to Dockerhub instead of GCR #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@ jobs:
- run:
name: Build
command: make image
- run: echo "$GCR_JSON_KEY" | docker login -u _json_key --password-stdin us.gcr.io
- run: echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
- run:
name: Push image to GCR
name: Push image to Dockerhub
command: |
docker tag codeclimate/codeclimate-sonar-php \
us.gcr.io/code-climate/codeclimate-sonar-php:b$CIRCLE_BUILD_NUM
docker push us.gcr.io/code-climate/codeclimate-sonar-php:b$CIRCLE_BUILD_NUM
make release RELEASE_TAG="b$CIRCLE_BUILD_NUM"
make release RELEASE_TAG="$(echo $CIRCLE_BRANCH | grep -oP 'channel/\K[\w\-]+')"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dantevvp does this means we will be pushing images like codeclimate-sonar-php:master ? if so which service will be using it ? I'm asking because I don't remember having seen an image tag :master before.

workflows:
version: 2
build_deploy:
jobs:
- build
- release_images:
context: Quality
requires:
- build
filters:
Expand Down
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
.PHONY: image test
.PHONY: image test release

IMAGE_NAME ?= codeclimate/codeclimate-sonar-php
RELEASE_REGISTRY ?= codeclimate

ifndef RELEASE_TAG
override RELEASE_TAG = latest
endif
Comment on lines +6 to +8
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ifndef RELEASE_TAG
override RELEASE_TAG = latest
endif
RELEASE_TAG ?= latest

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't that simpler ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this does not work when providing an empty string. Makefile takes empty strings as not null, so it'll end up not tagging the image as latest. The ifndef workaround lets us provide an empty string that will still be replaced with latest

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dantevvp

this does not work when providing an empty string.

That's expected isn't it ? Why would you run make release RELEASE_TAG="" ?


image:
docker build --rm -t $(IMAGE_NAME) .

test: image
docker run --rm -ti -w /usr/src/app -u root $(IMAGE_NAME) gradle clean test

release:
docker tag $(IMAGE_NAME) $(RELEASE_REGISTRY)/codeclimate-sonar-php:$(RELEASE_TAG)
docker push $(RELEASE_REGISTRY)/codeclimate-sonar-php:$(RELEASE_TAG)