-
Notifications
You must be signed in to change notification settings - Fork 53
/
Dockerfile
80 lines (63 loc) · 2.54 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
# 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-pack .
# dev runs the binary from devbuild
# -----------------------------------
FROM alpine:3.20.0 AS dev
RUN apk add --no-cache git libc6-compat tzdata
COPY --from=devbuild /build/nomad-pack /bin/
COPY ./scripts/docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["help"]
# ===================================
# Release images.
# ===================================
FROM alpine:3.20.0 AS release
ARG PRODUCT_NAME=nomad-pack
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-pack" \
org.opencontainers.image.description="Nomad Pack is a templating and packaging tool used with HashiCorp Nomad" \
org.opencontainers.image.authors="Nomad Team <[email protected]>" \
org.opencontainers.image.url="https://github.com/hashicorp/nomad-pack" \
org.opencontainers.image.documentation="https://github.com/hashicorp/nomad-pack/tree/main/docs" \
org.opencontainers.image.source="https://github.com/hashicorp/nomad-pack" \
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-pack
COPY LICENSE /usr/share/doc/nomad-pack/LICENSE.txt
RUN apk add --no-cache git libc6-compat tzdata
COPY dist/$TARGETOS/$TARGETARCH/nomad-pack /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 && \
mkdir -p /home/$PRODUCT_NAME/.cache && \
chown $PRODUCT_NAME /home/$PRODUCT_NAME/.cache
USER $PRODUCT_NAME
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["help"]
# ===================================
# Set default target to 'dev'.
# ===================================
FROM dev