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

Refactor the prow/cmd Dockerfiles to use shared base Dockerfiles #4900

Merged
merged 2 commits into from
Oct 5, 2017
Merged

Refactor the prow/cmd Dockerfiles to use shared base Dockerfiles #4900

merged 2 commits into from
Oct 5, 2017

Conversation

mattmoor
Copy link
Contributor

@mattmoor mattmoor commented Oct 5, 2017

... for common functionality

prow/cmd/*/Dockerfile basically has two classes of images:

  1. alpine:3.6 + ca-certs
  2. ^^ with git

This hoists those into common Dockerfiles under prow/cmd/alpine and prow/cmd/git respectively.

…nctionality

prow/cmd/*/Dockerfile basically has two classes of images:
1. alpine:3.6 + ca-certs
1. ^^ with git

This hoists those into common Dockerfiles under prow/cmd/alpine and prow/cmd/git respectively.
@mattmoor mattmoor requested a review from cjwagner as a code owner October 5, 2017 21:59
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Oct 5, 2017
@k8s-ci-robot
Copy link
Contributor

Hi @mattmoor. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

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 understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Oct 5, 2017
@BenTheElder
Copy link
Member

/ok-to-test
/area prow

@k8s-ci-robot k8s-ci-robot added area/prow Issues or PRs related to prow and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 5, 2017
@cjwagner
Copy link
Member

cjwagner commented Oct 5, 2017

The git and alpine directories could be put inside a prow/cmd/images directory instead of prow/cmd to distinguish them from the commands in prow/cmd.

@mattmoor
Copy link
Contributor Author

mattmoor commented Oct 5, 2017

Done.

@cjwagner
Copy link
Member

cjwagner commented Oct 5, 2017

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 5, 2017
@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cjwagner, mattmoor

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 5, 2017
@k8s-ci-robot k8s-ci-robot merged commit 6d81a81 into kubernetes:master Oct 5, 2017
@@ -12,10 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM alpine:3.6
FROM gcr.io/k8s-prow/alpine
Copy link
Contributor

Choose a reason for hiding this comment

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

These don't have any sort of version tag on them. How will we bump to 3.7 when it's time?

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'm happy to put in a 3.6, but wasn't sure what you'd want for git?

Copy link
Contributor

Choose a reason for hiding this comment

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

We can version the images separately from both alpine and git. I'm mainly afraid of confusions that come about when you rely on :latest.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is a parallel here to what's called out in "Building images" here.

I was talking to someone about this this morning, and frankly it's a weakness docker_build does not share because the base image intermediate artifact is expressed declaratively, but via an explicit def/use.

In the case of that post, you'd express FROM as:

docker_build(
   ...
  base = "//livegrep/base",
   ...
)

This is even easier with lang_image because it is containerization that "just works" (once you get Bazel to work), in their case they mention C++ and Go:

cc_image(   # same signature as cc_binary
   ...
  base = "//livegrep/base",  # doesn't have to be distroless!
  ...
)

go_image(   # same signature as go_binary
   ...
  base = "//livegrep/base",  # doesn't have to be distroless!
   ...
)

Once we get these base images published, my next PR was going to be to give you guys go_image with these base images, after which I can give you rules_k8s for the starter cluster.

Copy link
Contributor

Choose a reason for hiding this comment

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

Neat. Does it statically compile the go binary? Alpine doesn't have glibc and that can cause issues.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, but now that I see go_binary has added support for static linking I can add support for that. By default we use gcr.io/distroless/base which has glibc, ca-certs and a handful of other generally necessary things (e.g. tzdata, a /tmp directory, ...).

Perhaps I will add a :foo.static target that does what go_image does, but includes the static binary version of the image (this is how rules_go does 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.

Ugh, nevermind. Nothing is easy. (╯°□°)╯︵ ┻━┻

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright, I'm just going to add build --features=static and run --features=static to .bazelrc :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright, I sent a PR to make Bazel build static Go binaries in this repo (needs an update to rules_go). That should unblock putting these binaries onto the Alpine base images.

@0xmichalis
Copy link
Contributor

Can we ensure the new base images are pullable? I am getting manifest for gcr.io/k8s-prow/alpine:latest not found.

@mattmoor
Copy link
Contributor Author

mattmoor commented Oct 5, 2017

I don't have push access, what's the process?

@mattmoor mattmoor deleted the dockerfiles branch October 5, 2017 23:26
@cjwagner
Copy link
Member

cjwagner commented Oct 5, 2017

I can push the new images. We should add version tags first though as @spxtr suggested. Should we start our own version tags instead of using alpine's tag (i.e. start at 0.1)?

@mattmoor
Copy link
Contributor Author

mattmoor commented Oct 6, 2017

I'll put together a PR

@cjwagner
Copy link
Member

cjwagner commented Oct 6, 2017

@Kargakis I pushed the images. Both have tag 0.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/prow Issues or PRs related to prow cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants