-
Notifications
You must be signed in to change notification settings - Fork 260
[NPM] Update NPM base image to Distroless #3143
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
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,12 +2,36 @@ FROM mcr.microsoft.com/oss/go/microsoft/golang:1.23 AS builder | |
| ARG VERSION | ||
| ARG NPM_AI_PATH | ||
| ARG NPM_AI_ID | ||
| RUN apt-get update && apt-get install -y iptables ipset ca-certificates conntrack grep && apt-get autoremove -y && apt-get clean | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. make this a separate build stage to keep the concerns distinct and so it can parallelize - let the Go builder only build Go and we'll make an iptables target to get those bits. move to something like FROM mariner-core AS iptables
RUN tdnf install -y iptables etcthen change your copies to |
||
| WORKDIR /usr/local/src | ||
| COPY . . | ||
| RUN CGO_ENABLED=0 go build -v -o /usr/local/bin/azure-npm -ldflags "-X main.version="$VERSION" -X "$NPM_AI_PATH"="$NPM_AI_ID"" -gcflags="-dwarflocationlists=true" npm/cmd/*.go | ||
| RUN chmod +x /usr/local/bin/azure-npm | ||
|
|
||
| FROM mcr.microsoft.com/mirror/docker/library/ubuntu:20.04 as linux | ||
| FROM mcr.microsoft.com/cbl-mariner/distroless/minimal@sha256:63a0a70ceaa1320bc6eb98b81106667d43e46b674731ea8d28e4de1b87e0747f AS linux | ||
| COPY --from=builder /usr/local/bin/azure-npm /usr/bin/azure-npm | ||
| RUN apt-get update && apt-get install -y iptables ipset ca-certificates && apt-get autoremove -y && apt-get clean | ||
| RUN chmod +x /usr/bin/azure-npm | ||
| COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt | ||
| COPY --from=builder /lib/ /lib | ||
| COPY --from=builder /usr/lib/ /usr/lib | ||
| COPY --from=builder /usr/sbin/ /usr/sbin/ | ||
|
|
||
| # Copy iptables, iptables-nft, and iptables-nft-save binaries | ||
| COPY --from=builder /usr/sbin/iptables /usr/sbin/iptables | ||
| COPY --from=builder /usr/sbin/iptables-nft /usr/sbin/iptables-nft | ||
| COPY --from=builder /usr/sbin/iptables-restore /usr/sbin/iptables-restore | ||
| COPY --from=builder /usr/sbin/iptables-save /usr/sbin/iptables-save | ||
| COPY --from=builder /usr/sbin/iptables-nft-restore /usr/sbin/iptables-nft-restore | ||
| COPY --from=builder /usr/sbin/iptables-nft-save /usr/sbin/iptables-nft-save | ||
| COPY --from=builder /usr/sbin/conntrack /usr/sbin/conntrack | ||
| COPY --from=builder /bin/grep /bin/grep | ||
|
|
||
| # Copy required libraries based on ldd output | ||
| COPY --from=builder /lib/x86_64-linux-gnu/libxtables.so.12 /lib/x86_64-linux-gnu/libxtables.so.12 | ||
| COPY --from=builder /lib/x86_64-linux-gnu/libmnl.so.0 /lib/x86_64-linux-gnu/libmnl.so.0 | ||
| COPY --from=builder /lib/x86_64-linux-gnu/libnftnl.so.11 /lib/x86_64-linux-gnu/libnftnl.so.11 | ||
| COPY --from=builder /lib/x86_64-linux-gnu/libnetfilter_conntrack.so.3 /lib/x86_64-linux-gnu/libnetfilter_conntrack.so.3 | ||
| COPY --from=builder /lib/x86_64-linux-gnu/libnfnetlink.so.0 /lib/x86_64-linux-gnu/libnfnetlink.so.0 | ||
| COPY --from=builder /lib/x86_64-linux-gnu/libc.so.6 /lib/x86_64-linux-gnu/libc.so.6 | ||
| COPY --from=builder /lib64/ld-linux-x86-64.so.2 /lib64/ld-linux-x86-64.so.2 | ||
|
|
||
| ENTRYPOINT ["/usr/bin/azure-npm", "start"] | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
going to need a
\