forked from hashicorp/vault-benchmark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
69 lines (53 loc) · 1.71 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0
# This Dockerfile contains multiple targets.
# Use 'docker build --target=<name> .' to build one.
#
# Every target has a BIN_NAME argument that must be provided via --build-arg=BIN_NAME=<name>
# when building.
# ===================================
#
# Non-release images.
#
# ===================================
# devbuild compiles the binary
# -----------------------------------
FROM golang:latest AS devbuild
ARG BIN_NAME=vault-benchmark
# Escape the GOPATH
WORKDIR /build
COPY . ./
RUN go build -o $BIN_NAME
# dev runs the binary from devbuild
# -----------------------------------
FROM alpine:latest AS dev
ARG BIN_NAME=vault-benchmark
# Export BIN_NAME for the CMD below, it can't see ARGs directly.
ENV BIN_NAME=$BIN_NAME
COPY --from=devbuild /build/$BIN_NAME /bin/
CMD /bin/$BIN_NAME
# ===================================
#
# Release images.
#
# ===================================
# default release image
# -----------------------------------
FROM alpine:latest AS release-default
ARG BIN_NAME=vault-benchmark
# Export BIN_NAME for the CMD below, it can't see ARGs directly.
ENV BIN_NAME=$BIN_NAME
ARG PRODUCT_VERSION
ARG PRODUCT_REVISION
ARG PRODUCT_NAME=$BIN_NAME
# TARGETARCH and TARGETOS are set automatically when --platform is provided.
ARG TARGETOS TARGETARCH
LABEL maintainer="Team Vault Customer Engineering <team-vault-customer-engineering@hashicorp.com>"
LABEL version=$PRODUCT_VERSION
LABEL revision=$PRODUCT_REVISION
# Create a non-root user to run the software.
RUN addgroup $PRODUCT_NAME && \
adduser -S -G $PRODUCT_NAME $PRODUCT_NAME
COPY dist/$TARGETOS/$TARGETARCH/$BIN_NAME /bin/
USER $PRODUCT_NAME
CMD ["/bin/vault-benchmark"]