Skip to content

Commit

Permalink
Cleanup Docker context and decrease build time
Browse files Browse the repository at this point in the history
This is based off the work found in kubernetes-sigs#1307 that was never merged. It
moves around the install and copy of certain conponents to take better
advantage of the Docker cache ad well as drops running tests during the
build of the image.

The reason for dropping tests is to improve build time and as running
tests within the build while they're already being run in CI seems like
an unnecessary added tax.

Signed-off-by: Danny Grove <danny@drgrovellc.com>
  • Loading branch information
drGrove committed Jun 18, 2020
1 parent 0f186d3 commit 6411306
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 9 deletions.
14 changes: 14 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Git Related Items
.git
.github
.gitignore

# CI Related Items
.travis.yml
cloudbuild.yaml
.golangci.yml
.zappr.yaml

# Other
docs
OWNERS
9 changes: 6 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ ARG VERSION

WORKDIR /sigs.k8s.io/external-dns

COPY . .
COPY go.mod .
COPY go.sum .
RUN go mod vendor && \
make test && \
make build
go mod download

COPY . .
RUN make build

# final image
FROM alpine:3.11.5
Expand Down
17 changes: 11 additions & 6 deletions Dockerfile.mini
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,18 @@ FROM golang:1.14 as builder

WORKDIR /sigs.k8s.io/external-dns

RUN apt-get update \
&& apt-get install \
ca-certificates \
&& update-ca-certificates

COPY go.mod .
COPY go.sum .
RUN go mod vendor && \
go mod download

COPY . .
RUN apt-get update && \
apt-get install ca-certificates && \
update-ca-certificates && \
go mod vendor && \
make test && \
make build
RUN make build

FROM gcr.io/distroless/static

Expand Down

0 comments on commit 6411306

Please sign in to comment.