-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #479 from jhkimqd/jihwan/dockerfile
fix: dockerfile build
- Loading branch information
Showing
3 changed files
with
22 additions
and
23 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
tmp/ |
This file contains 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 |
---|---|---|
@@ -1,31 +1,25 @@ | ||
FROM golang:1.22 AS builder | ||
# Build stage | ||
FROM --platform=${BUILDPLATFORM} golang:1.22 AS builder | ||
|
||
# Set the workspace for the build | ||
WORKDIR /workspace | ||
|
||
# Copy only necessary Go module files for caching dependencies | ||
COPY go.mod go.sum ./ | ||
RUN go mod download | ||
|
||
COPY abi/ abi/ | ||
COPY bindings/ bindings/ | ||
COPY cmd/ cmd/ | ||
COPY dashboard/ dashboard/ | ||
COPY gethkeystore/ gethkeystore/ | ||
COPY hdwallet/ hdwallet/ | ||
COPY metrics/ metrics/ | ||
COPY p2p/ p2p/ | ||
COPY proto/ proto/ | ||
COPY rpctypes/ rpctypes/ | ||
COPY util/ util/ | ||
COPY main.go ./ | ||
RUN CGO_ENABLED=0 go build -o polycli main.go | ||
# Copy the necessary source code | ||
COPY . ./ | ||
|
||
# Build the Go binary | ||
RUN go build -o /workspace/polycli main.go | ||
|
||
# Final stage: minimal base image | ||
FROM --platform=${BUILDPLATFORM} debian:bookworm-slim | ||
|
||
# Use distroless as minimal base image to package the manager binary | ||
# Refer to https://github.com/GoogleContainerTools/distroless for more details | ||
FROM gcr.io/distroless/static:nonroot | ||
WORKDIR / | ||
# Copy only the necessary files from the builder image | ||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt | ||
COPY --from=builder /workspace/polycli /usr/bin/polycli | ||
USER 65532:65532 | ||
ENTRYPOINT ["polycli"] | ||
CMD ["--help"] | ||
|
||
# How to test this image? | ||
# https://github.com/0xPolygon/polygon-cli/pull/189#discussion_r1464486344 | ||
# Default cmd for the container | ||
ENTRYPOINT ["polycli"] |
This file contains 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