Cleanup Docker context and decrease build time

This is based off the work found in #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>
This commit is contained in:
Danny Grove 2020-04-08 09:57:59 -07:00
parent 44288212d8
commit 2226e00bd6
No known key found for this signature in database
GPG Key ID: E1F4160251DB4C2E
3 changed files with 30 additions and 7 deletions

15
.dockerignore Normal file
View File

@ -0,0 +1,15 @@
# Git Related Items
.git
.github
.gitignore
# CI Related Items
.travis.yml
cloudbuild.yaml
.golangci.yml
.zappr.yaml
# Other
docs
OWNERS
vendor

View File

@ -19,8 +19,12 @@ ARG ARCH
WORKDIR /sigs.k8s.io/external-dns
COPY go.mod .
COPY go.sum .
RUN go mod download
COPY . .
RUN make test && make build.$ARCH
RUN make test build.$ARCH
# final image
FROM $ARCH/alpine:3.12

View File

@ -16,13 +16,17 @@ FROM golang:1.15 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 download
COPY . .
RUN apt-get update && \
apt-get install ca-certificates && \
update-ca-certificates && \
go mod vendor && \
make test && \
make build
RUN make test build
FROM gcr.io/distroless/static