-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add caching to dockerfile; remove no longer required nsswitch.c…
…onf overrides Signed-off-by: Liam Stanley <[email protected]>
- Loading branch information
Showing
1 changed file
with
13 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,29 @@ | ||
# syntax = docker/dockerfile:1.4 | ||
|
||
# build image | ||
FROM golang:alpine as build | ||
WORKDIR /build | ||
|
||
RUN apk add --no-cache make | ||
COPY go.sum go.mod Makefile /build/ | ||
RUN make go-fetch | ||
RUN \ | ||
--mount=type=cache,target=/root/.cache \ | ||
--mount=type=cache,target=/go \ | ||
make go-fetch | ||
|
||
COPY . /build/ | ||
RUN make | ||
RUN \ | ||
--mount=type=cache,target=/root/.cache \ | ||
--mount=type=cache,target=/go \ | ||
make | ||
|
||
# runtime image | ||
FROM alpine:3.18 | ||
RUN apk add --no-cache ca-certificates | ||
# set up nsswitch.conf for Go's "netgo" implementation | ||
# - https://github.com/docker-library/golang/blob/1eb096131592bcbc90aa3b97471811c798a93573/1.14/alpine3.12/Dockerfile#L9 | ||
RUN if [ ! -e /etc/nsswitch.conf ];then echo 'hosts: files dns' > /etc/nsswitch.conf;fi | ||
COPY --from=build /build/vault-unseal /usr/local/bin/vault-unseal | ||
|
||
# runtime params | ||
WORKDIR / | ||
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin | ||
ENV LOG_JSON=true | ||
CMD ["vault-unseal"] | ||
CMD ["/usr/local/bin/vault-unseal"] |