-
Notifications
You must be signed in to change notification settings - Fork 34
/
Dockerfile
49 lines (38 loc) · 1.1 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
# This is a multi-stage build.
# build stage
FROM golang:1.18 AS builder
WORKDIR /go/src/hargo
COPY . /go/src/hargo
ARG VERSION
ARG HASH
ARG DATE
ENV GOPROXY=direct
RUN go mod download
ENV CGO_ENABLED=0
ENV GOOS=linux
RUN go build -ldflags "-s -w -X main.Version=$VERSION -X main.CommitHash=$HASH -X 'main.CompileDate=$DATE'" -o hargo ./cmd/hargo
# final stage
FROM scratch
WORKDIR /
ENV PATH=/
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /go/src/hargo/hargo /
# Metadata params
ARG VERSION
ARG BUILD_DATE
ARG VCS_URL
ARG VCS_REF
ARG NAME
ARG VENDOR
# Metadata
LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name=$NAME \
org.label-schema.description="hargo" \
org.label-schema.url="https://markrichman.com" \
org.label-schema.vcs-url=https://github.com/mrichman/$VCS_URL \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vendor=$VENDOR \
org.label-schema.version=$VERSION \
org.label-schema.docker.schema-version="1.0" \
org.label-schema.docker.cmd="docker run --rm hargo"
CMD ["./hargo"]