34 lines
1015 B
Docker
34 lines
1015 B
Docker
ARG BUILD_FROM
|
|
|
|
FROM golang:1.14-alpine3.12 AS builder
|
|
|
|
WORKDIR /workspace/observer-plugin
|
|
ARG BUILD_ARCH
|
|
|
|
COPY . .
|
|
|
|
# Build
|
|
RUN \
|
|
if [ "${BUILD_ARCH}" = "armhf" ]; then \
|
|
CGO_ENABLED=0 GOARM=6 GOARCH=arm go build -ldflags="-s -w"; \
|
|
elif [ "${BUILD_ARCH}" = "armv7" ]; then \
|
|
CGO_ENABLED=0 GOARM=7 GOARCH=arm go build -ldflags="-s -w"; \
|
|
elif [ "${BUILD_ARCH}" = "aarch64" ]; then \
|
|
CGO_ENABLED=0 GOARCH=arm64 go build -ldflags="-s -w"; \
|
|
elif [ "${BUILD_ARCH}" = "i386" ]; then \
|
|
CGO_ENABLED=0 GOARCH=386 go build -ldflags="-s -w"; \
|
|
elif [ "${BUILD_ARCH}" = "amd64" ]; then \
|
|
CGO_ENABLED=0 GOARCH=amd64 go build -ldflags="-s -w"; \
|
|
else \
|
|
exit 1; \
|
|
fi \
|
|
&& cp -f landingpage /workspace/landingpage \
|
|
&& rm -rf /workspace/landingpage
|
|
|
|
|
|
FROM ${BUILD_FROM}
|
|
|
|
WORKDIR /
|
|
COPY --from=builder /workspace/landingpage /usr/bin/landingpage
|
|
COPY rootfs /
|