Skip to content

Commit

Permalink
Merge pull request #48 from bman46/update-docker-build
Browse files Browse the repository at this point in the history
Use Alpine For Docker Base Image
  • Loading branch information
lxlxok authored Jun 14, 2023
2 parents d6e3139 + 5b50e6b commit 3a8bd5e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1 AS build
FROM golang:1-alpine AS build

WORKDIR /sidecarinjector
COPY go.mod go.sum ./
Expand All @@ -8,12 +8,14 @@ RUN go mod download
COPY . ./
COPY pkg ./pkg

RUN apk --no-cache add git

RUN GIT_HASH=$(git rev-parse --short HEAD) && GIT_TAG=$(git tag | tail -1) && \
CGO_ENABLED=0 && GOOS=linux && GOARCH=amd64 && \
echo "GIT_HASH=$GIT_HASH" && echo "GIT_TAG=$GIT_TAG" && \
go build -ldflags "-X 'github.com/salesforce/generic-sidecar-injector/pkg/metrics.gitHash=$GIT_HASH' -X 'github.com/salesforce/generic-sidecar-injector/pkg/metrics.gitTag=$GIT_TAG' -s" -installsuffix cgo -o sidecarinjector ./cmd/sidecarinjector

FROM golang:1
FROM golang:1-alpine
COPY --from=build /sidecarinjector/sidecarinjector /sidecarinjector
ENV PATH="/:${PATH}"
CMD ["/sidecarinjector"]

0 comments on commit 3a8bd5e

Please sign in to comment.