Skip to content

Commit

Permalink
Merge pull request #807 from salasberryfin/improve-dockerfile-build-time
Browse files Browse the repository at this point in the history
chore: remove redundant steps in docker build
  • Loading branch information
salasberryfin authored Oct 25, 2024
2 parents 17fac77 + 9ec15a2 commit 3edf9ef
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 25 deletions.
9 changes: 0 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,6 @@ ARG goproxy=https://proxy.golang.org
# Run this with docker build --build-arg package=./controlplane or --build-arg package=./bootstrap
ENV GOPROXY=$goproxy

# 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 --mount=type=cache,target=/go/pkg/mod \
go mod download

COPY ./ ./

# Build
Expand Down
18 changes: 2 additions & 16 deletions exp/etcdrestore/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,10 @@ ARG goproxy=https://proxy.golang.org
# Run this with docker build --build-arg package=./exp/etcdrestore
ENV GOPROXY=$goproxy

# Copy the Go Modules manifests
COPY exp/etcdrestore/go.mod /go.mod
COPY exp/etcdrestore/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 --mount=type=cache,target=/go/pkg/mod \
go mod download

# Copy the sources
COPY ./ ./

# Cache the go build into the Go’s compiler cache folder so we take benefits of compiler caching across docker build calls
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
sh -c "cd exp/etcdrestore && go build ."

# # Build
# Build
ARG ARCH
ARG ldflags

Expand All @@ -67,4 +53,4 @@ WORKDIR /
COPY --from=builder /workspace/exp/etcdrestore/manager .
# Use uid of nonroot user (65532) because kubernetes expects numeric user when applying pod security policies
USER 65532
ENTRYPOINT ["/manager"]
ENTRYPOINT ["/manager"]

0 comments on commit 3edf9ef

Please sign in to comment.