https://pantsbuild.org/ logo
#general
Title
# general
a

ambitious-actor-36781

09/30/2021, 5:35 AM
@curved-television-6568 not sure if you'd consider it a bug. But I have multiple customers, and each of which have a creatively named
base
docker image (amongst other conflicting image names) the solution for this was change all their build/deploy scripts to name their docker images
<companyname>/base
or similar. Buuuut, I can't do that with the 2.7 pants
docker_image
target, because
/
is a disallowed target name. Is there a way to specify the image name of a
docker_image
target to be something other than the
name
property?
💯 1
h

hundreds-father-404

09/30/2021, 5:37 AM
Oh good point! @curved-television-6568 I'm about to head to bed but I wonder if OutputPathField from package.py would be applicable
a

ambitious-actor-36781

09/30/2021, 5:37 AM
Considered engaging some janky macro to prefix all the names with
<companyname>__
but 😬
c

curved-television-6568

09/30/2021, 5:37 AM
It's next up to add a field for repo, and customizations for the name part.
❤️ 1
So yeah, bug/missing feature.
a

ambitious-actor-36781

09/30/2021, 5:38 AM
👍
c

curved-television-6568

09/30/2021, 5:39 AM
With the latetst upcoming 2.8 dev, you can put the repo at the end of the registry address ad a hack..
a

ambitious-actor-36781

09/30/2021, 5:40 AM
I guess, another thing to consider. all our images are
Copy code
FROM <companyname>/base
but the container registry is
<http://eu.gcr.io/whatever/|eu.gcr.io/whatever/>...
which'd make tying the two together also problematic.
(fun fact: company #1s base image runs company #2s code 80% effectively. that was a fun day of debugging)
c

curved-television-6568

09/30/2021, 6:10 AM
Yeah, we use this in ours (not supported in Pants, yet)
Copy code
ARG REGISTRY
FROM ${REGISTRY}/
… Where the build arg is picked up from env var. Will introduce something similar for Pants. Not sure what it will look like yet.
Oh, and thank you so much for the feedback. It is invaluable! :)
a

ambitious-actor-36781

09/30/2021, 6:26 AM
👍 happy to help.
c

curved-television-6568

09/30/2021, 6:29 AM
@hundreds-father-404 I don't think OutputPath really applies, as it does not land on the fs directly, and the image name isn't really path-like either..
👍 1
a

ambitious-actor-36781

09/30/2021, 6:30 AM
docker images are so... half-baked. names, labels, tags, ids, registries, 😖
c

curved-television-6568

09/30/2021, 6:51 AM
Speaking of Docker tags, I’m trying to decide whether to use the
tags
field for additional tags on the image, such as
"latest"
, or use a new field for that.. wdyt? I’m most concerned with how it would impact other goals/options, such as list and filter etc..
a

ambitious-actor-36781

09/30/2021, 7:10 AM
isn't the
tags
field used for things like target pruning?
which would mean:
./pants --tag=deployable publish ::
pushes
my_image:deployable
c

curved-television-6568

09/30/2021, 7:13 AM
Yeah, so I think that
tags
is the perfect field name but perhaps not the best choice for that very reason..
👍 1
a

ambitious-actor-36781

09/30/2021, 7:14 AM
in my half-baked docker-build implementation anything associated with the image itself i've prefixed with
image_
i.e.
image_name
and
image_tags
c

curved-television-6568

09/30/2021, 7:16 AM
That’s reasonable.
And so
image_name
could default to target name, if not specified…
a

ambitious-actor-36781

09/30/2021, 7:17 AM
yep
c

curved-television-6568

09/30/2021, 7:18 AM
And for repo, I’m thinking of having a
[docker].default_repository
option, and support to optionally use a trailing part of the target address for repo, so you can re-use your directory structure for that purpose..
a

ambitious-actor-36781

09/30/2021, 7:23 AM
I think that checks out. But one thing to consider, and maybe I'm an edge-case. But I did build support for multiple-repositories because that's a use-case we have. Push everything to 'our' repositories. And then some customer libraries to a customer-exposed repository.
👍 1
could probably bodge that together in additional scripting, so maybe it's not that important. but something to consider, I'm probably not the only one out there.
c

curved-television-6568

09/30/2021, 7:28 AM
I love edge cases. If you cover the edges well, everything else falls into place. 🙂
❤️ 1
Ah, right, so I just introduced the
registry
field, which in your case would better be
registries
, and tagging each accordingly then.. hmm.. Thanks for the heads up on that 🙂
a

ambitious-actor-36781

09/30/2021, 7:31 AM
we do the same with pypi too fyi
c

curved-television-6568

09/30/2021, 7:32 AM
Yeah, I remember that part from your publish PR.. my head just wasn’t at that place then… 😛
a

ambitious-actor-36781

09/30/2021, 7:32 AM
ha
c

curved-television-6568

09/30/2021, 11:47 AM
@ambitious-actor-36781 take a look at https://github.com/pantsbuild/pants/pull/13048. Hopefully, that will cover your docker image naming needs.
h

happy-kitchen-89482

09/30/2021, 3:35 PM
I definitely wouldn't use
tags
for that, as it has special meaning in Pants, as you noted.
image_tags
?
docker_tags
?
1
c

curved-television-6568

09/30/2021, 3:37 PM
Yeah, went with
image_tags
, it’s in the PR 🙂
h

happy-kitchen-89482

09/30/2021, 3:38 PM
Hah, I'm working through the PRs in order, so I didn't see that one when I commented to that effect on the other one...
c

curved-television-6568

09/30/2021, 3:38 PM
It’s fine 😛
I’m currently touching up on @ambitious-actor-36781 publish PR using FieldSets rather than a custom union. See if I have anything ready for tonight, otherwise tomorrow hopefully..