2024-01-04 04:39:47 +00:00
|
|
|
ARG TARGETOS
|
|
|
|
ARG TARGETARCH
|
|
|
|
|
|
|
|
FROM golang:1.21-alpine AS builder
|
|
|
|
|
2024-01-04 05:23:12 +00:00
|
|
|
RUN apk add --no-cache git=~2 && mkdir /app
|
2024-01-04 04:39:47 +00:00
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
COPY ./go.mod ./go.sum /app/
|
|
|
|
RUN go mod download
|
|
|
|
|
|
|
|
COPY ./*.go /app/
|
|
|
|
|
|
|
|
ARG VERSION=dev
|
|
|
|
ENV CGO_ENABLED=0 GOOS=TARGETOS GOARCH=TARGETARCH
|
|
|
|
RUN go build -ldflags "-X main.version=VERSION" -a -installsuffix nocgo -o nomad-var-dirsync .
|
|
|
|
|
|
|
|
FROM REPO/alpine:3.19
|
|
|
|
RUN mkdir /app
|
|
|
|
WORKDIR /app/
|
|
|
|
|
|
|
|
# Copy binary in
|
|
|
|
COPY --from=builder /app/nomad-var-dirsync .
|
|
|
|
|
|
|
|
# Add user for running as non-root
|
|
|
|
RUN addgroup -S nomad-var-dirsync && adduser -S nomad-var-dirsync -G nomad-var-dirsync
|
|
|
|
|
|
|
|
# Drop to non-root user
|
|
|
|
USER nomad-var-dirsync
|
|
|
|
|
|
|
|
ENTRYPOINT [ "./nomad-var-dirsync" ]
|
|
|
|
|
|
|
|
# vim: set filetype=dockerfile:
|