FROM golang:alpine AS build
RUN apk --no-cache add gcc g++ make git

WORKDIR /go/src/app

COPY . .
RUN go get ./...
RUN GOOS=linux go build -ldflags="-s -w" -o ./bin/vault-wrap ./vault.go
FROM alpine:3.20
RUN apk add tzdata
#RUN apk --no-cache add ca-certificates
WORKDIR /usr/bin
COPY --from=build /go/src/app/bin /go/bin

# COPY cronjobs /etc/crontabs/root

./bin/vault-wrap -action-address "${ADDRESS}" -vault-url "${VAULT_ADDRESS}" -tls-cert "${TLS_CERT}" -tls-key "${TLS_KEY}"
# start crond with log level 8 in foreground, output to stderr
# CMD ["crond", "-f", "-d", "8"]