-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
119 lines (94 loc) · 3.7 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: Apache-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.
#
# ===================================
# go-discover builds the discover binary (which we don't currently publish
# either).
FROM golang:1.19.2-alpine as go-discover
RUN CGO_ENABLED=0 go install github.com/hashicorp/go-discover/cmd/discover@49f60c093101c9c5f6b04d5b1c80164251a761a6
# dev copies the binary from a local build
# -----------------------------------
# BIN_NAME is a requirement in the hashicorp docker github action
FROM alpine:3.17 AS dev
# NAME and VERSION are the name of the software in releases.hashicorp.com
# and the version to download. Example: NAME=consul VERSION=1.2.3.
ARG BIN_NAME=rollouts-plugin-trafficrouter-consul
ARG VERSION
ARG TARGETARCH
ARG TARGETOS
ENV PRODUCT_NAME=$BIN_NAME
LABEL name=${BIN_NAME} \
maintainer="Team Consul Kubernetes <[email protected]>" \
vendor="HashiCorp" \
version=${VERSION} \
release=${VERSION} \
licenses="Apache-2.0" \
summary="rollouts-plugin-trafficrouter-consul is a plugin for Argo Rollouts." \
description="rollouts-plugin-trafficrouter-consul is a plugin for Argo Rollouts."
# Set ARGs as ENV so that they can be used in ENTRYPOINT/CMD
ENV BIN_NAME=${BIN_NAME}
ENV VERSION=${VERSION}
RUN apk add --no-cache ca-certificates libcap openssl su-exec iputils libc6-compat iptables
# Create a non-root user to run the software.
RUN addgroup ${BIN_NAME} && \
adduser -S -G ${BIN_NAME} 100
COPY LICENSE /usr/share/doc/$PRODUCT_NAME/LICENSE.txt
COPY --from=go-discover /go/bin/discover /bin/
COPY pkg/bin/linux_${TARGETARCH}/${BIN_NAME} /bin
USER 100
CMD /bin/${BIN_NAME}
# ===================================
#
# Release images.
#
# ===================================
# default release image
# -----------------------------------
# This Dockerfile creates a production release image for the project. This
# downloads the release from releases.hashicorp.com and therefore requires that
# the release is published before building the Docker image.
#
# We don't rebuild the software because we want the exact checksums and
# binary signatures to match the software and our builds aren't fully
# reproducible currently.
FROM alpine:3.17 AS release-default
ARG BIN_NAME=rollouts-plugin-trafficrouter-consul
ARG PRODUCT_VERSION
ENV PRODUCT_NAME=$BIN_NAME
LABEL name=${BIN_NAME} \
maintainer="Team Consul Kubernetes <[email protected]>" \
vendor="HashiCorp" \
version=${PRODUCT_VERSION} \
release=${PRODUCT_VERSION} \
licenses="Apache-2.0" \
summary="rollouts-plugin-trafficrouter-consul is a plugin for Argo Rollouts" \
description="rollouts-plugin-trafficrouter-consul is a plugin for Argo Rollouts."
# Set ARGs as ENV so that they can be used in ENTRYPOINT/CMD
ENV BIN_NAME=${BIN_NAME}
ENV VERSION=${PRODUCT_VERSION}
RUN apk add --no-cache ca-certificates libcap openssl su-exec iputils libc6-compat iptables
# TARGETOS and TARGETARCH are set automatically when --platform is provided.
ARG TARGETOS
ARG TARGETARCH
# Create a non-root user to run the software.
RUN addgroup ${BIN_NAME} && \
adduser -S -G ${BIN_NAME} 100
COPY LICENSE /usr/share/doc/$PRODUCT_NAME/LICENSE.txt
COPY --from=go-discover /go/bin/discover /bin/
COPY dist/${TARGETOS}/${TARGETARCH}/${BIN_NAME} /bin/
USER 100
CMD /bin/${BIN_NAME}
# ===================================
#
# Set default target to 'dev'.
#
# ===================================
FROM dev