Skip to content

Commit

Permalink
Optimize build speed
Browse files Browse the repository at this point in the history
Removing -a means the template can use a cache and doesn't
need to rebuild the image every time.

This is much quicker.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
  • Loading branch information
alexellis committed Feb 21, 2023
1 parent e490943 commit e3d205e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions template/golang-http/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} GOFLAGS=${GOFLAGS} go test ./... -cove

WORKDIR /go/src/handler
RUN CGO_ENABLED=${CGO_ENABLED} GOOS=${TARGETOS} GOARCH=${TARGETARCH} GOFLAGS=${GOFLAGS} \
go build --ldflags "-s -w" -a -installsuffix cgo -o handler .
go build --ldflags "-s -w" -o handler .

FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.17.1 as ship
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.17.2 as ship
# Add non root user and certs

RUN apk --no-cache add ca-certificates \
Expand Down
4 changes: 2 additions & 2 deletions template/golang-middleware/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} go test ./... -cover

WORKDIR /go/src/handler
RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
go build --ldflags "-s -w" -a -installsuffix cgo -o handler .
go build --ldflags "-s -w" -o handler .

FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.17.1 as ship
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.17.2 as ship

# Add non root user and certs
RUN apk --no-cache add ca-certificates \
Expand Down

0 comments on commit e3d205e

Please sign in to comment.