-
Notifications
You must be signed in to change notification settings - Fork 42
/
Dockerfile
78 lines (65 loc) · 2.63 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
72
73
74
75
76
77
78
ARG GOLANG_VERSION
FROM library/golang:${GOLANG_VERSION}-alpine AS build
ARG TAG
RUN set -x \
&& apk --no-cache add \
bash \
curl \
git \
tar
COPY ./scripts/semver-parse.sh /semver-parse.sh
RUN chmod +x /semver-parse.sh
RUN curl -sL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s v1.43.0
RUN git clone -b $(/semver-parse.sh ${TAG} all) --depth=1 https://github.com/flannel-io/cni-plugin ${GOPATH}/src/github.com/flannel-io/cni-plugin
WORKDIR ${GOPATH}/src/github.com/flannel-io/cni-plugin
FROM build AS flannel-cni
ARG TAG
WORKDIR ${GOPATH}/src/github.com/flannel-io/cni-plugin
RUN \
set -ex; \
source ./scripts/version.sh; \
chmod +x ./scripts/*
ENV SRC_DIR=${SRC_DIR:-${pwd}}
ENV DOCKER=${DOCKER:-docker}
ENV GO=${GO:-go}
ENV GOPATH=${GOPATH:-'${go env GOPATH}'}
ENV RELEASE_DIR=${GOPATH}/src/github.com/flannel-io/cni-plugin/release-${TAG}
ENV OUTPUT_DIR=${GOPATH}/src/github.com/flannel-io/cni-plugin/dist
# Always clean first
RUN \
rm -rf ${OUTPUT_DIR} \
&& rm -rf ${RELEASE_DIR} \
&& mkdir -p ${RELEASE_DIR} \
&& mkdir -p ${OUTPUT_DIR}
RUN go mod vendor && go mod tidy
# for ARCH IN ${ALL_ARCH}; do
RUN \
for arch in amd64 386 arm arm64 s390x ppc64le riscv64; do \
GOARCH=${arch} ./scripts/build_flannel.sh; \
for format in tgz; do \
FILENAME=cni-plugin-flannel-linux-${arch}-${TAG}.${format}; \
FILEPATH=${RELEASE_DIR}/${FILENAME}; \
tar -C ${OUTPUT_DIR} --owner=0 --group=0 -caf ${FILEPATH} . ; \
done; \
done
RUN \
GOOS=windows GOARCH=amd64 ./scripts/build_flannel.sh; \
for format in tgz; do \
FILENAME=cni-plugin-flannel-windows-${GOARCH}-${TAG}.${format}; \
FILEPATH=${RELEASE_DIR}/${FILENAME}; \
tar -C ${OUTPUT_DIR} --owner=0 --group=0 -caf ${FILEPATH} . ; \
done
RUN \
for arch in amd64 386 arm arm64 s390x ppc64le riscv64; do \
GOARCH=${arch} ./scripts/check_static.sh >> static-check.log; \
done
WORKDIR ${RELEASE_DIR}
RUN \
for f in *.tgz; do sha1sum ${f} > ./${f}.sha1; done; \
for f in *.tgz; do sha256sum ${f} > ./${f}.sha256; done; \
for f in *.tgz; do sha512sum ${f} > ./${f}.sha512; done;
FROM build AS flannel-cni-collect
ARG TAG
COPY --from=flannel-cni ${GOPATH}/src/github.com/flannel-io/cni-plugin/dist/ /go/src/github.com/flannel-io/cni-plugin/dist/
COPY --from=flannel-cni ${GOPATH}/src/github.com/flannel-io/cni-plugin/release-${TAG}/ /go/src/github.com/flannel-io/cni-plugin/release-${TAG}/
COPY --from=flannel-cni ${GOPATH}/src/github.com/flannel-io/cni-plugin/static-check.log /go/src/github.com/flannel-io/cni-plugin/static-check.log