Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: odubajDT <[email protected]>
  • Loading branch information
odubajDT committed Apr 26, 2024
1 parent aff3062 commit eb13caa
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,16 @@ RUN go mod download
# Copy the go source
COPY main.go main.go
COPY apis/ apis/
COPY apis/flagd-schemas/ apis/flagd-schemas/
COPY webhooks/ webhooks/
COPY controllers/ controllers/
COPY common/ common/

ARG TARGETOS
ARG TARGETARCH

# Download dependencies as a separate step to take advantage of Docker's caching.
# Leverage a cache mount to /go/pkg/mod/ to speed up subsequent builds.
# Leverage bind mounts to go.sum and go.mod to avoid having to copy them into
# the container.
RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=bind,source=./apis/go.mod,target=./apis/go.mod \
--mount=type=bind,source=./apis/go.sum,target=./apis/go.sum \
go work init ./apis && go mod download

# Build the application.
# Leverage a cache mount to /go/pkg/mod/ to speed up subsequent builds.
# Leverage a bind mount to the current directory to avoid having to copy the
# source code into the container.
RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=cache,target=/root/.cache/go-build \
--mount=type=bind,source=./apis,target=./apis \
CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -a -o manager main.go
# Build
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -a -o manager main.go

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
Expand Down

0 comments on commit eb13caa

Please sign in to comment.