-
Notifications
You must be signed in to change notification settings - Fork 83
/
Dockerfile
77 lines (59 loc) · 2.41 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
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0
# This Dockerfile contains multiple targets.
# Use 'docker build --target=<name> .' to build one.
# ===================================
# Non-release images.
# ===================================
# devbuild compiles the binary
# -----------------------------------
FROM golang:1.23 AS devbuild
# Disable CGO to make sure we build static binaries
ENV CGO_ENABLED=0
# Escape the GOPATH
WORKDIR /build
COPY . ./
RUN go build -o nomad-autoscaler .
# dev runs the binary from devbuild
# -----------------------------------
FROM alpine:3.20 AS dev
COPY --from=devbuild /build/nomad-autoscaler /bin/
COPY ./scripts/docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["help"]
# ===================================
# Release images.
# ===================================
FROM alpine:3.20 AS release
ARG PRODUCT_NAME=nomad-autoscaler
ARG PRODUCT_VERSION
ARG PRODUCT_REVISION
# TARGETARCH and TARGETOS are set automatically when --platform is provided.
ARG TARGETOS TARGETARCH
LABEL maintainer="Nomad Team <[email protected]>" \
version=${PRODUCT_VERSION} \
revision=${PRODUCT_REVISION} \
org.opencontainers.image.title="nomad-autoscaler" \
org.opencontainers.image.description="Nomad Autoscaler is a horizontal application and cluster autoscaler for HashiCorp Nomad" \
org.opencontainers.image.authors="Nomad Team <[email protected]>" \
org.opencontainers.image.url="https://github.com/hashicorp/nomad-autoscaler" \
org.opencontainers.image.documentation="https://developer.hashicorp.com/nomad/tools/autoscaling" \
org.opencontainers.image.source="https://github.com/hashicorp/nomad-autoscaler" \
org.opencontainers.image.version=${PRODUCT_VERSION} \
org.opencontainers.image.revision=${PRODUCT_REVISION} \
org.opencontainers.image.vendor="HashiCorp" \
org.opencontainers.image.licenses="MPL-2.0"
RUN mkdir -p /usr/share/doc/nomad-autoscaler
COPY LICENSE /usr/share/doc/nomad-autoscaler/LICENSE.txt
COPY dist/$TARGETOS/$TARGETARCH/nomad-autoscaler /bin/
COPY ./scripts/docker-entrypoint.sh /
# Create a non-root user to run the software.
RUN addgroup $PRODUCT_NAME && \
adduser -S -G $PRODUCT_NAME $PRODUCT_NAME
USER $PRODUCT_NAME
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["help"]
# ===================================
# Set default target to 'dev'.
# ===================================
FROM dev