Skip to content

Commit

Permalink
feat: add caching to dockerfile; remove no longer required nsswitch.c…
Browse files Browse the repository at this point in the history
…onf overrides

Signed-off-by: Liam Stanley <[email protected]>
  • Loading branch information
lrstanley committed Sep 11, 2023
1 parent 4a7b643 commit 10b96b9
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions Dockerfile
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"]

0 comments on commit 10b96b9

Please sign in to comment.