/
Dockerfile
40 lines (23 loc) · 880 Bytes
/
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
# vi: ft=Dockerfile:
ARG GO_VERSION=1.20
FROM --platform=$BUILDPLATFORM golang:$GO_VERSION AS builder
RUN apt-get update && apt-get dist-upgrade -y && apt-get install -y build-essential git
WORKDIR $GOPATH/src/sylr.dev/yage
COPY go.mod go.sum ./
RUN go mod download
COPY . .
ARG TARGETPLATFORM
ARG TARGETOS
ARG TARGETARCH
ARG TARGETVARIANT
# Switch shell to bash
SHELL ["bash", "-c"]
# Run a git command otherwise git describe in the Makefile could report a dirty git dir
RUN git diff --exit-code || true
RUN make build GOOS=${TARGETOS} GOARCH=${TARGETARCH} GOARM=${TARGETVARIANT/v/} GO_BUILD_TARGET=dist/${TARGETPLATFORM}/yage
# -----------------------------------------------------------------------------
FROM scratch
ARG TARGETPLATFORM
WORKDIR /usr/local/bin
COPY --from=builder "/go/src/sylr.dev/yage/dist/$TARGETPLATFORM/yage" .
CMD ["/usr/local/bin/yage"]