-
Notifications
You must be signed in to change notification settings - Fork 17
/
Dockerfile
37 lines (28 loc) · 1.08 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
ARG BUILD_FROM
FROM --platform=amd64 golang:1.19-alpine3.16 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 plugin-observer /workspace/observer \
&& rm -rf /workspace/observer-plugin
FROM ${BUILD_FROM}
ENV DOCKER_HOST="unix:///run/docker.sock"
WORKDIR /
COPY --from=builder /workspace/observer /usr/bin/observer
COPY rootfs /
ENTRYPOINT ["/usr/bin/observer"]