2018-04-10 11:15:41 +00:00
|
|
|
FROM golang:alpine as builder
|
|
|
|
|
2020-09-12 23:42:28 +00:00
|
|
|
{{ if hasFeature "private-mods" -}}
|
|
|
|
ARG VAULT_ADDR
|
|
|
|
ARG VAULT_TOKEN
|
|
|
|
|
|
|
|
RUN set -ex \
|
|
|
|
&& apk --no-cache add git \
|
|
|
|
&& GOPATH=/usr/local go get -u -v github.com/Luzifer/git-credential-vault \
|
|
|
|
&& git config --global credential.helper 'vault --vault-path-prefix secret/jenkins/git-credential'
|
|
|
|
{{- end }}
|
|
|
|
|
2018-09-20 14:28:08 +00:00
|
|
|
COPY . /go/src/{{ .package }}
|
2018-04-10 11:15:41 +00:00
|
|
|
WORKDIR /go/src/{{ .package }}
|
|
|
|
|
|
|
|
RUN set -ex \
|
|
|
|
&& apk add --update git \
|
2019-09-12 14:09:24 +00:00
|
|
|
&& go install \
|
|
|
|
-ldflags "-X main.version=$(git describe --tags --always || echo dev)" \
|
|
|
|
-mod=readonly
|
2018-04-10 11:15:41 +00:00
|
|
|
|
|
|
|
FROM alpine:latest
|
|
|
|
|
|
|
|
LABEL maintainer "{{ .git_name }} <{{ .git_mail }}>"
|
|
|
|
|
|
|
|
RUN set -ex \
|
|
|
|
{{ if ne .timezone "" -}}
|
|
|
|
&& apk --no-cache add tzdata \
|
|
|
|
&& cp /usr/share/zoneinfo/{{ .timezone }} /etc/localtime \
|
|
|
|
&& echo "{{ .timezone }}" > /etc/timezone \
|
|
|
|
&& apk --no-cache del --purge tzdata \
|
|
|
|
{{- end -}}
|
2019-09-12 14:09:24 +00:00
|
|
|
&& apk --no-cache add \
|
|
|
|
ca-certificates
|
2018-04-10 11:15:41 +00:00
|
|
|
|
|
|
|
COPY --from=builder /go/bin/{{ .binary }} /usr/local/bin/{{ .binary }}
|
|
|
|
|
|
|
|
{{ if .expose }}EXPOSE{{ range .expose }} {{.}}{{ end }}{{end}}
|
|
|
|
{{ if ne .volumes `""` }}VOLUME [{{ .volumes }}]{{ end }}
|
|
|
|
|
|
|
|
ENTRYPOINT ["/usr/local/bin/{{ .binary }}"]
|
|
|
|
CMD ["--"]
|
|
|
|
|
|
|
|
# vim: set ft=Dockerfile:
|