forked from koordinator-sh/koordetector
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
init dockerfile & makefile (koordinator-sh#8)
Signed-off-by: songtao98 <[email protected]>
- Loading branch information
Showing
4 changed files
with
172 additions
and
508 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
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,32 +1,19 @@ | ||
# Build the manager binary | ||
FROM golang:1.17 as builder | ||
ARG TARGETOS | ||
ARG TARGETARCH | ||
WORKDIR /go/src/github.com/koordinator-sh/koordetector | ||
|
||
WORKDIR /workspace | ||
# Copy the Go Modules manifests | ||
COPY ../go.mod go.mod | ||
COPY ../go.sum go.sum | ||
# cache deps before building and copying source so that we don't need to re-download as much | ||
# and so that source changes don't invalidate our downloaded layer | ||
|
||
RUN go mod download | ||
|
||
# Copy the go source | ||
COPY main.go main.go | ||
COPY api/ api/ | ||
COPY ../pkg/interferencemanager/controllers controllers/ | ||
COPY apis/ apis/ | ||
COPY cmd/ cmd/ | ||
COPY pkg/ pkg/ | ||
|
||
# Build | ||
# the GOARCH has not a default value to allow the binary be built according to the host where the command | ||
# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO | ||
# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore, | ||
# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform. | ||
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager main.go | ||
RUN GOOS=linux GOARCH=amd64 go build -a -o interference-manager cmd/interference-manager/main.go | ||
|
||
# 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 --from=builder /workspace/manager . | ||
|
||
ENTRYPOINT ["/manager"] | ||
COPY --from=builder /go/src/github.com/koordinator-sh/koordetector/interference-manager . | ||
ENTRYPOINT ["/interference-manager"] |
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
Oops, something went wrong.