-
Notifications
You must be signed in to change notification settings - Fork 697
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
Introduce "generate" command #1002
Introduce "generate" command #1002
Conversation
Hi @isutton. Thanks for your PR. I'm waiting for a openshift member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
i would definitely want to see --as-dockerfile deprecated when this new command is introduced, to avoid user confusion about which to use and differences in behavior between the two. |
Naming wise I suggest calling this new sub-command |
I'm not sure about doing both at the same time, but I would definitely release a minor to introduce the command, and a major to remove the |
Thanks @isutton and @otaviof for this, and thank you @bparees for taking a quick look. Even though I find My worry is:
I would love to remove (2) entirely to avoid this. Or move (3) into (2). @siamaksade , thoughts? |
why not get rid of (2) entirely to avoid this? |
(long term, after a deprecation period) |
👍 to removing (2) . I think we should do it as part of a version 1.x release? |
+1 to removal. Now that we are switching to go modules, v2 may come sooner than we think. Any refactor that removes or alters an exported method/constant requires a major version bump. https://github.com/golang/go/wiki/Modules#semantic-import-versioning |
I was hoping v2 would look a lot more different ( a lot more breaking changes ;) ), but I'm good with getting to v2 sooner, and maybe postpone bigger changes to a future version. |
The past couple of days @otaviof and I have been enabling buildah in s2i from start to end (#1003), and since this effort is being quite successful I'd like to propose a strategy for aligning that PR and this one. As stated previously, the
There are a couple of points I'm still unsure:
My take on this is to finalize #1003, since it will enable s2i to build an application image without requiring a Docker socket, making it suitable to run in Tekton, Travis CI and other build pipelines. Additionally, it also gives us the foundation to produce an accurate Dockerfile based on the existing s2i build workflow. |
https://github.com/openshift/builder does use the Dockerfile generation flow and then does a lot of other things. So, I wouldn't want to comment on the future of Dockerfile generation. Dockerfile generation is handy because it lets us separate the concern of 'define strategy' v/s 'build the image using a strategy'. So, irrespective of #1003 , we would need this to be in ASAP. |
+1. i think there is a lot of value in avoiding tying s2i to runtime libraries both on the inspection/generation side as well as the image construction side. |
/ok-to-test |
/retest |
2 similar comments
/retest |
/retest |
/test all |
/refresh |
/retest |
Fixed in cbcc36a. |
All |
Is there anything I can do to move this PR and finalize this piece of work? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@isutton General logic here looks good. I think we can refactor the getImageLabels
function in a follow-up PR, since openshift/builder implements its own logic to set image labels.
I'm worried a bit about the go mod bumps. From what I can gather all we need is containers/image/v5
and its dependencies.
Finally, these commits need to be squashed. I'd like to see the following:
- A clean commit with the dependencies bumped in
go.mod
andgo.sum
- A
bump(*)
commit with the vendor updates. - A commit with the new functionality
github.com/containerd/fifo v0.0.0-20190816180239-bda0ff6ed73c // indirect | ||
github.com/containers/image/v5 v5.0.0 | ||
github.com/coreos/etcd v3.3.17+incompatible // indirect | ||
github.com/docker/distribution v2.7.1-0.20190205005809-0d3efadf0154+incompatible |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be ok - docker/distribution on openshift/builder is 2.7.1
github.com/docker/distribution v2.6.0-rc.1.0.20170726174610-edc3ab29cdff+incompatible | ||
github.com/docker/docker v0.0.0-20190404075923-dbe4a30928d4 | ||
github.com/containerd/fifo v0.0.0-20190816180239-bda0ff6ed73c // indirect | ||
github.com/containers/image/v5 v5.0.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is ok - containers/image uses strict semvers so we won't have transitive dep conflicts in openshift/builder
pkg/cmd/cli/cmd/generate.go
Outdated
Short: "Generate a Dockerfile based on the provided builder image", | ||
Example: ` | ||
# Generate a Dockerfile from a remote builder image: | ||
$ s2i generate docker://quay.io/redhat-developer/app-binding-operator Dockerfile.gen |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd use one of our canonical s2i images as an example - docker.io/centos/nodejs-10-centos7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@isutton Could you please make the above change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@isutton please update the example here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also a bit of a nit - is it worth switching the order around? Thoughts on the following semantics?
$ s2i generate DOCKERFILE [IMAGE]
or
$ s2i generate DOCKERFILE --from=[IMAGE]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I understood, IMAGE is always required in this use case since there's no information regarding that; additionally, the protocol currently must be informed by the user to refer to the image since containers/image
is responsible for retrieving its contents and inspecting its labels.
I believe the following example is closer to what we want, where DOCKERFILE could have the Dockerfile
value by default:
$ s2i generate IMAGE [DOCKERFILE]
During implementation, I opted for DOCKERFILE to be mandatory and not having defaults to avoid unwillingly Dockerfile overwrites.
The requested example modification has been made.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, IMAGE is always required since it is the s2i builder image. I think Adam is OK with that.
I do like s2i generate DOCKERFILE --from=quay.io/builder/image
instead of
s2i generate quay.io/builder/image Dockerfile.gen
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I understood, IMAGE is always required in this use case since there's no information regarding that;
Correct
During implementation, I opted for DOCKERFILE to be mandatory and not having defaults to avoid unwillingly Dockerfile overwrites.
I agree with this choice for now. We can always opt to make it optional later; I have other ideas on how to arrange the arguments to this command that are worth discussing in a follow-up PR.
pkg/cmd/cli/cmd/generate.go
Outdated
cfg.BuilderImage = cmd.Flags().Arg(0) | ||
cfg.AsDockerfile = cmd.Flags().Arg(1) | ||
|
||
ctx := context.TODO() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
context.Background()
is acceptable here, since this is effectively the main entrypoint to the command.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 7eb02e7.
go.mod
Outdated
github.com/moby/buildkit => github.com/dmcgowan/buildkit v0.0.0-20170731200553-da2b9dc7dab9 | ||
github.com/Sirupsen/logrus => github.com/sirupsen/logrus v1.2.0 | ||
github.com/containerd/containerd => github.com/containerd/containerd v1.3.0 | ||
github.com/docker/docker => github.com/docker/docker v0.0.0-20180522102801-da99009bbb11 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docker has been downgraded here - why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To use the same Docker version containers/image
is using:
github.com/Sirupsen/logrus => github.com/sirupsen/logrus v1.2.0 | ||
github.com/containerd/containerd => github.com/containerd/containerd v1.3.0 | ||
github.com/docker/docker => github.com/docker/docker v0.0.0-20180522102801-da99009bbb11 | ||
golang.org/x/crypto => golang.org/x/crypto v0.0.0-20180904163835-0709b304e793 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
golang.org/x/crypto
has been added in the replace stanza, but is not referenced in the require
stanza. Why is this necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After I did my first changes, I noticed that make test
didn't work. After I dug into it, I've noticed that buildkit and swarmkit should be updated as well, and this lead to all those dependencies
Tests use buildkit and swarmkit, which also had to be bumped and adjusted (see 9f3ead4 for reference).
Sounds fine.
Will do. |
@isutton note that we recently merged a |
7eb02e7
to
eaa5d08
Compare
eaa5d08
to
677a104
Compare
677a104
to
c8e4429
Compare
c8e4429
to
554280f
Compare
I think this is now ready? |
I've updated the branch according to the project's guidelines. /cc @adambkaplan @sbose78 |
@adambkaplan Should we take this in? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general this looks good - only have the remaining nit on the example. @sbose78 I'd like you and perhaps @otaviof to weigh in on my comment regarding the command line argument order. Given our prior difficulties with go.mod
, I need to verify the dep changes work with golang 1.13.
@isutton thanks so much for the effort you've put in thus far. I think we're almost there.
pkg/cmd/cli/cmd/generate.go
Outdated
Short: "Generate a Dockerfile based on the provided builder image", | ||
Example: ` | ||
# Generate a Dockerfile from a remote builder image: | ||
$ s2i generate docker://quay.io/redhat-developer/app-binding-operator Dockerfile.gen |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@isutton please update the example here.
pkg/cmd/cli/cmd/generate.go
Outdated
Short: "Generate a Dockerfile based on the provided builder image", | ||
Example: ` | ||
# Generate a Dockerfile from a remote builder image: | ||
$ s2i generate docker://quay.io/redhat-developer/app-binding-operator Dockerfile.gen |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also a bit of a nit - is it worth switching the order around? Thoughts on the following semantics?
$ s2i generate DOCKERFILE [IMAGE]
or
$ s2i generate DOCKERFILE --from=[IMAGE]
This change adds the generate command to s2i, where it allows the user to produce a Dockerfile able to be used by any build system supporting the format, such as buildah and possibly others.
554280f
to
f8dcf74
Compare
/approve /lgtm Will follow up on my "other ideas" I have for the cli args. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: adambkaplan, isutton The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
This PR create a new s2i top level command,
generate
.The choice to create this command instead of just implementing the same functionality in the
build --as-dockerfile
flow, is that the semantics of builder image would change betweenbuild
andbuild --as-dockerfile
; the former would reflect changes made to local images, where the latter would ignore those. This meanss2i build my-image .
ands2i build --as-dockerfile my-image . | buildah
commands could produce different results.This new command expects the given builder image name to be available on a remote registry, and is inspected through the infrastructure provided by
containers/image
.Once OCI support is implemented in s2i, this command could benefit and provide transparent access to local images as well, since it would delegate the inspection task to the container runtime itself and even deprecate
build --as-dockerfile
.This PR requires some dependencies to be updated, since it depends on containers/image, and both depended (and still depend) on Docker.
In cli.go the
gen-dockerfile
command is registered.In dockerfile.go, the
CreateDockerfile()
method was modified to inherit bothscripts-url
anddestination
labels.gen-dockerfile.go is a new file, where the command is implemented.
In go.mod, dependency to containers/image was added, together with replacements for indirect dependencies based on containers/image
go.mod
file.