-
Notifications
You must be signed in to change notification settings - Fork 4
/
dockerfile
71 lines (46 loc) · 1.38 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
ARG ALPINE_VERSION=3.15
FROM alpine:${ALPINE_VERSION} AS build-env
ARG GO_VERSION=1.17.2
ARG BUILD_OS=linux
ARG BUILD_ARCH=amd64
WORKDIR /build
RUN set -eux; \
apk add --no-cache \
bash \
libc6-compat
RUN set -eux; \
wget -O go.tar.gz "https://dl.google.com/go/go${GO_VERSION}.${BUILD_OS}-${BUILD_ARCH}.tar.gz" ; \
tar -C /usr/local/ -xzf go.tar.gz; \
rm -f go.tar.gz
ENV GOPATH=/go
ENV GOFLAGS="-v -mod=readonly -mod=vendor"
ENV GO111MODULE=on
ENV CGO_ENABLED=0
ENV PATH="${GOPATH}/bin:/usr/local/go/bin:${PATH}"
RUN go version
FROM build-env AS rbedit-builder
ARG TARGET_OS
ARG TARGET_ARCH
ARG BUILD_MARKDOWN=no
ENV GOOS="${TARGET_OS}"
ENV GOARCH="${TARGET_ARCH}"
COPY ./ ./
RUN set -eux; \
echo "GOOS=${GOOS}"; \
echo "GOARCH=${GOARCH}"; \
\
go build -ldflags "-s -w -extldflags '-static -fno-PIC'" -o "/rbedit-${GOOS}-${GOARCH}" ./cmd/rbedit; \
\
if [ "${BUILD_MARKDOWN}" == "yes" ]; then \
go build -ldflags "-s -w -extldflags '-static -fno-PIC'" -o "/rbedit-markdown-${GOOS}-${GOARCH}" ./cmd/rbedit-markdown; \
fi
FROM scratch AS rbedit
ARG TARGET_OS
ARG TARGET_ARCH
COPY --from=rbedit-builder "/rbedit-${TARGET_OS}-${TARGET_ARCH}" /rbedit
ENTRYPOINT ["/rbedit"]
FROM scratch AS rbedit-markdown
ARG TARGET_OS
ARG TARGET_ARCH
COPY --from=rbedit-builder "/rbedit-markdown-${TARGET_OS}-${TARGET_ARCH}" /rbedit-markdown
ENTRYPOINT ["/rbedit-markdown"]