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

Distroless base image for crd-client #3277

Merged
merged 5 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
15 changes: 6 additions & 9 deletions examples/crd-client/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,18 @@

# Gather dependencies and build the executable
FROM golang:1.20.4 as builder
WORKDIR /go/src/crd-client
WORKDIR /
Copy link
Member

Choose a reason for hiding this comment

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

I'm curious why you changed the paths in the build container. That shouldn't affect the location in the final container.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mark suggested moving the WORKDIR path to the root directory ('/').
Example PR: https://github.com/googleforgames/agones/pull/3270/files

Copy link
Member

Choose a reason for hiding this comment

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

I was being consistent with everything else I've seen with distroless / done with distroless.

There's no $HOME folders in distroless, so it seems like everyone drops everything in /.

Copy link
Member

Choose a reason for hiding this comment

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

Oh sorry, I should have looked at this properly - this is the build step.

🤷🏻 actually for this, I have no strong opinion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Based on testing, the change to the root directory ('/') for WORKDIR in the build container didn't work as expected, so I've reverted it back.


COPY ./main.go .
RUN go mod init && go mod tidy
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o client .

# Create the final image that will run the webhook server for FleetAutoscaler webhook policy
FROM alpine:3.13.1
RUN adduser -D -u 1000 client
FROM gcr.io/distroless/static-debian11:nonroot

COPY --from=builder /go/src/crd-client \
/home/client
COPY --from=builder /client /
Copy link
Member

Choose a reason for hiding this comment

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

I do like just copying the binary over; that seems like an improvement from the previous commands. 👍


RUN chown -R client /home/client && \
chmod o+x /home/client/client
RUN chmod o+x /client

USER 1000
ENTRYPOINT /home/client/client
USER nonroot:nonroot
ENTRYPOINT /client
2 changes: 1 addition & 1 deletion examples/crd-client/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

REPOSITORY ?= us-docker.pkg.dev/agones-images/examples

server_tag = $(REPOSITORY)/crd-client:0.9
server_tag = $(REPOSITORY)/crd-client:1.0
Copy link
Member

Choose a reason for hiding this comment

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

@markmandel - how do you feel about going from 0.9 to 1.0 vs. 0.9 to 0.10? Are we happy calling this image a 1.0 image?

Copy link
Member

Choose a reason for hiding this comment

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

That's a good point - I figure let's go to 0.10 -- examples can always change I guess (or at least we should be consistent with our examples).

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 changed it to 0.10


# _____ _
# |_ _|_ _ _ __ __ _ ___| |_ ___
Expand Down
2 changes: 1 addition & 1 deletion examples/crd-client/create-gs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ spec:
cpu: 500m
ephemeral-storage: 1Gi
memory: 2Gi
image: us-docker.pkg.dev/agones-images/examples/crd-client:0.9
image: us-docker.pkg.dev/agones-images/examples/crd-client:1.0
imagePullPolicy: Always
env:
- name: GAMESERVER_IMAGE
Expand Down
2 changes: 1 addition & 1 deletion install/helm/agones/templates/tests/test-runner.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ spec:
serviceAccountName: agones-controller
containers:
- name: create-gameserver
image: us-docker.pkg.dev/agones-images/examples/crd-client:0.9
image: us-docker.pkg.dev/agones-images/examples/crd-client:1.0
imagePullPolicy: Always
env:
- name: GAMESERVER_IMAGE
Expand Down
Loading