Skip to content
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

NOISSUE - Add MF_DOCKER_IMAGE_NAME_PREFIX to Makefile #1173

Merged
merged 1 commit into from
Jun 3, 2020

Conversation

sprql
Copy link
Contributor

@sprql sprql commented May 12, 2020

Allow custom docker image names

@sprql sprql requested a review from a team as a code owner May 12, 2020 14:22
Makefile Outdated
@@ -7,6 +7,7 @@ SERVICES = users things http coap lora influxdb-writer influxdb-reader mongodb-w
bootstrap opcua authn twins mqtt provision
DOCKERS = $(addprefix docker_,$(SERVICES))
DOCKERS_DEV = $(addprefix docker_dev_,$(SERVICES))
DOCKER_IMAGE_NAME_PREFIX ?= ""
Copy link
Contributor

@manuio manuio May 12, 2020

Choose a reason for hiding this comment

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

I would use mainflux as prefix here and I would remove it where it's hard-coded.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've thought about it but I'm confused about what to do with /:
should be / part of DOCKER_IMAGE_NAME_PREFIX or not.

Copy link
Contributor

Choose a reason for hiding this comment

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

I prefer to keep it outside but let's see what others think about

Copy link
Contributor

Choose a reason for hiding this comment

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

@manuio I think mainflux should be default, and then <docker_registry_url>/mainflux can be used for other cases.

I preferred previous implementation, looks cleaner and more configurable.

Copy link
Contributor

Choose a reason for hiding this comment

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

@drasko I'm no sure to understand. I proposed DOCKER_IMAGE_NAME_PREFIX ?= "mainflux"
and $(DOCKER_IMAGE_NAME_PREFIX)/$(svc) to simplify an eventual renaming and because it's hard-coded for many commands.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, cool - then we are on the same page.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good, I made MF_DOCKER_IMAGE_NAME_PREFIX ?= mainflux/

Copy link
Contributor

Choose a reason for hiding this comment

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

We proposed mainflux, not mainflux/ ;)

Copy link
Contributor Author

@sprql sprql Jun 3, 2020

Choose a reason for hiding this comment

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

ok, updated:

MF_DOCKER_IMAGE_NAME_PREFIX ?= mainflux

@drasko
Copy link
Contributor

drasko commented May 27, 2020

I do not see a great value of this PR in the core (mostly because of additional code complexity for no big gains).

@sprql what is the particular use-case that you have to name images differently?

I think that this might be some particular use-case, which can probably be solved with a simple custom script (or even shell one-liner) that renames Mainflux images, but I would like to first hear from you the requirement.

@sprql
Copy link
Contributor Author

sprql commented Jun 1, 2020

@drasko It's very handy for custom builds, for example when using different docker registry.
Yes, it is possible to create custom shell scripts, but isn't it easier to solve this in the first place, in Makefile?

I think it's better to introduce MF_DOCKER_IMAGE_NAME_PREFIX env var, so it will be easy to export it in a shell.

@drasko
Copy link
Contributor

drasko commented Jun 1, 2020

...for example when using different docker registry.

Can you please elaborate on this, because I think that even in the private registries (non-DockerHub) you can have mainflux/<service_name>. Or am I wrong?

@sprql
Copy link
Contributor Author

sprql commented Jun 1, 2020

@drasko, as I know, to push an image to non-DockerHub registry I should specify host and port in the Docker image name. So to push mainflux/service:v1 to registry.example.com I should tag the image with registry.example.com/mainflux/service:v1 and then push it as registry.example.com/mainflux/service:v1

https://docs.docker.com/engine/reference/commandline/push/

Maybe there is another approach which I don't know…

@drasko
Copy link
Contributor

drasko commented Jun 1, 2020

I see... I thought that you can give a param to docker push in some other way, but apparently not.

OK, this is good enough reason to add this prefix to the core. Please update the branch and I will do the review.

Makefile Outdated
@@ -7,6 +7,7 @@ SERVICES = users things http coap lora influxdb-writer influxdb-reader mongodb-w
bootstrap opcua authn twins mqtt provision
DOCKERS = $(addprefix docker_,$(SERVICES))
DOCKERS_DEV = $(addprefix docker_dev_,$(SERVICES))
DOCKER_IMAGE_NAME_PREFIX ?= ""
Copy link
Contributor

Choose a reason for hiding this comment

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

@manuio I think mainflux should be default, and then <docker_registry_url>/mainflux can be used for other cases.

I preferred previous implementation, looks cleaner and more configurable.

Makefile Outdated Show resolved Hide resolved
@sprql sprql force-pushed the feature/docker-tag-prefix branch from 81be906 to 6651e2c Compare June 2, 2020 13:55
@sprql sprql changed the title NOISSUE - Add DOCKER_IMAGE_NAME_PREFIX to Makefile NOISSUE - Add MF_DOCKER_IMAGE_NAME_PREFIX to Makefile Jun 2, 2020
Makefile Outdated
@@ -1,6 +1,7 @@
# Copyright (c) Mainflux
# SPDX-License-Identifier: Apache-2.0

MF_DOCKER_IMAGE_NAME_PREFIX ?= mainflux/
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just mainflux? I would prefer that service is always prefixed with some name, then followed by /, so you can have $(MF_DOCKER_IMAGE_NAME_PREFIX)/$(svc)

It is more readable then concatenated like this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought it would be more flexible

@sprql sprql force-pushed the feature/docker-tag-prefix branch from 6651e2c to d5df272 Compare June 3, 2020 08:38
drasko
drasko previously approved these changes Jun 3, 2020
Copy link
Contributor

@drasko drasko left a comment

Choose a reason for hiding this comment

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

LGTM

manuio
manuio previously approved these changes Jun 3, 2020
Copy link
Contributor

@manuio manuio left a comment

Choose a reason for hiding this comment

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

LGTM

@manuio
Copy link
Contributor

manuio commented Jun 3, 2020

@sprql update your branch please

@sprql sprql dismissed stale reviews from manuio and drasko via 117c7ea June 3, 2020 09:27
@sprql sprql force-pushed the feature/docker-tag-prefix branch from d5df272 to 117c7ea Compare June 3, 2020 09:27
@manuio
Copy link
Contributor

manuio commented Jun 3, 2020

@sprql Please, can you update again your branch? We had an issue with the CI...

Signed-off-by: Alexander Obukhov <dev@sprql.space>
@sprql sprql force-pushed the feature/docker-tag-prefix branch from 117c7ea to 87df445 Compare June 3, 2020 18:05
@codecov-commenter
Copy link

Codecov Report

Merging #1173 into master will increase coverage by 0.02%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1173      +/-   ##
==========================================
+ Coverage   77.23%   77.25%   +0.02%     
==========================================
  Files         102      102              
  Lines        6816     6816              
==========================================
+ Hits         5264     5266       +2     
+ Misses       1182     1180       -2     
  Partials      370      370              
Impacted Files Coverage Δ
things/service.go 86.33% <0.00%> (+1.43%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a7c3cfc...87df445. Read the comment docs.


# Remove unused images
docker images "mainflux\/*" -f dangling=true -q | xargs -r docker rmi
docker images "$(MF_DOCKER_IMAGE_NAME_PREFIX)\/*" -f dangling=true -q | xargs -r docker rmi
Copy link
Contributor

Choose a reason for hiding this comment

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

Are the quotes really needed in "$(MF_DOCKER_IMAGE_NAME_PREFIX)\/*" or can be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it depends on that is sh on your system

Copy link
Contributor

@manuio manuio left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@drasko drasko left a comment

Choose a reason for hiding this comment

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

LGTM

@drasko drasko merged commit 8b004b3 into absmach:master Jun 3, 2020
manuio pushed a commit that referenced this pull request Oct 12, 2020
Signed-off-by: Alexander Obukhov <dev@sprql.space>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants