forked from rancher/rancher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.dapper
151 lines (128 loc) · 6.48 KB
/
Dockerfile.dapper
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
ARG K3S_BUILDER=rancher/k3s:v1.23.3-k3s1
# Use binaries from k3s root for s390x as k3s is not available on s390x
FROM registry.suse.com/bci/golang:1.17 AS k3s_root
ARG DAPPER_HOST_ARCH
ENV ARCH=${DAPPER_HOST_ARCH}
ENV K3S_ROOT_VERSION v0.11.0
ONBUILD RUN zypper -n in tar
ONBUILD ADD https://github.com/rancher/k3s-root/releases/download/${K3S_ROOT_VERSION}/k3s-root-${ARCH}.tar /k3s-root.tar
ONBUILD RUN tar xvf /k3s-root.tar; \
touch /bin/cni /bin/containerd /bin/containerd-shim-runc-v2 /bin/runc /bin/k3s
FROM ${K3S_BUILDER} as k3s_builder
FROM registry.suse.com/bci/golang:1.17
ARG DAPPER_HOST_ARCH
ENV HOST_ARCH=${DAPPER_HOST_ARCH} ARCH=${DAPPER_HOST_ARCH}
ENV CATTLE_HELM_VERSION v2.16.8-rancher1
ENV CATTLE_MACHINE_VERSION v0.15.0-rancher81
ENV CATTLE_K3S_VERSION v1.23.3+k3s1
# version used by helm plugin install script
ENV CATTLE_HELM_UNITTEST_VERSION v0.1.7-rancher3
# helm 3 version
ENV HELM_VERSION v3.8.0
ENV KUSTOMIZE_VERSION v4.4.1
# kontainer-driver-metadata branch to be set for specific branch other than dev/master, logic at rancher/rancher/pkg/settings/setting.go
ENV CATTLE_KDM_BRANCH=dev-v2.6
RUN zypper -n install gcc binutils glibc-devel-static ca-certificates git-core wget curl unzip tar vim less file xz gzip sed gawk iproute2 iptables jq
RUN zypper install -y -f docker
RUN curl -sLf https://github.com/rancher/machine/releases/download/${CATTLE_MACHINE_VERSION}/rancher-machine-${ARCH}.tar.gz | tar xvzf - -C /usr/bin
RUN zypper -n in go1.17
RUN if [ "${ARCH}" == "amd64" ]; then \
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.44.0; \
curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/spectrometer/master/install.sh | sh; \
fi
# workaround for https://bugzilla.suse.com/show_bug.cgi?id=1183043
RUN if [ "${ARCH}" == "arm64" ]; then \
zypper -n install binutils-gold ; \
fi
ENV HELM_URL_V2_amd64=https://github.com/rancher/helm/releases/download/${CATTLE_HELM_VERSION}/rancher-helm \
HELM_URL_V2_arm64=https://github.com/rancher/helm/releases/download/${CATTLE_HELM_VERSION}/rancher-helm-arm64 \
HELM_URL_V2=HELM_URL_V2_${ARCH} \
HELM_URL_V3=https://get.helm.sh/helm-${HELM_VERSION}-linux-${ARCH}.tar.gz \
TILLER_URL_amd64=https://github.com/rancher/helm/releases/download/${CATTLE_HELM_VERSION}/rancher-tiller \
TILLER_URL_arm64=https://github.com/rancher/helm/releases/download/${CATTLE_HELM_VERSION}/rancher-tiller-arm64 \
TILLER_URL=TILLER_URL_${ARCH} \
KUSTOMIZE_URL=https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/${KUSTOMIZE_VERSION}/kustomize_${KUSTOMIZE_VERSION}_linux_${ARCH}.tar.gz
RUN curl -sLf ${KUSTOMIZE_URL} | tar -xzf - -C /usr/bin
# set up helm 2 to all archs other than s390x
RUN if [ "${ARCH}" != "s390x" ]; then \
curl -sLf ${!HELM_URL_V2} -o /usr/bin/rancher-helm && \
curl -sLf ${!TILLER_URL} -o /usr/bin/rancher-tiller && \
chmod +x /usr/bin/rancher-helm /usr/bin/rancher-tiller && \
ln -s /usr/bin/rancher-helm /usr/bin/helm && \
ln -s /usr/bin/rancher-tiller /usr/bin/tiller && \
helm init -c --stable-repo-url https://charts.helm.sh/stable/ && \
helm plugin install https://github.com/rancher/helm-unittest; \
fi
# set up helm 3
RUN mkdir /usr/tmp && \
curl ${HELM_URL_V3} | tar xvzf - --strip-components=1 -C /usr/tmp/ && \
mv /usr/tmp/helm /usr/bin/helm_v3 && \
chmod +x /usr/bin/kustomize
# Set up K3s: copy the necessary binaries from the K3s image.
COPY --from=k3s_builder \
/bin/blkid \
/bin/charon \
/bin/cni \
/bin/conntrack \
/bin/containerd \
/bin/containerd-shim-runc-v2 \
/bin/ethtool \
/bin/ip \
/bin/ipset \
/bin/k3s \
/bin/losetup \
/bin/pigz \
/bin/runc \
/bin/swanctl \
/bin/which \
/bin/aux/xtables-legacy-multi \
/usr/bin/
RUN mkdir -p /go/src/github.com/rancher/rancher/.kube
RUN if [ "${ARCH}" != "s390x" ]; then \
ln -s /usr/bin/cni /usr/bin/bridge && \
ln -s /usr/bin/cni /usr/bin/flannel && \
ln -s /usr/bin/cni /usr/bin/host-local && \
ln -s /usr/bin/cni /usr/bin/loopback && \
ln -s /usr/bin/cni /usr/bin/portmap && \
ln -s /usr/bin/k3s /usr/bin/crictl && \
ln -s /usr/bin/k3s /usr/bin/ctr && \
ln -s /usr/bin/k3s /usr/bin/k3s-agent && \
ln -s /usr/bin/k3s /usr/bin/k3s-etcd-snapshot && \
ln -s /usr/bin/k3s /usr/bin/k3s-server && \
ln -s /usr/bin/k3s /usr/bin/kubectl && \
ln -s /usr/bin/pigz /usr/bin/unpigz && \
ln -s /usr/bin/xtables-legacy-multi /usr/bin/iptables && \
ln -s /usr/bin/xtables-legacy-multi /usr/bin/iptables-save && \
ln -s /usr/bin/xtables-legacy-multi /usr/bin/iptables-restore && \
ln -s /usr/bin/xtables-legacy-multi /usr/bin/iptables-translate && \
ln -s /usr/bin/xtables-legacy-multi /usr/bin/ip6tables && \
ln -s /usr/bin/xtables-legacy-multi /usr/bin/ip6tables-save && \
ln -s /usr/bin/xtables-legacy-multi /usr/bin/ip6tables-restore && \
ln -s /usr/bin/xtables-legacy-multi /usr/bin/ip6tables-translate && \
ln -s /etc/rancher/k3s/k3s.yaml /go/src/github.com/rancher/rancher/.kube/k3s.yaml; \
else \
# Download kubectl for s390x since k3s is not available
KUBECTL_URL=https://storage.googleapis.com/kubernetes-release/release/v1.21.7/bin/linux/${ARCH}/kubectl; \
curl -sLf ${KUBECTL_URL} -o /usr/bin/kubectl && chmod +x /usr/bin/kubectl; \
fi
# Add k3s for all archs except s390x since k3s doesn't support s390x
RUN if [ "${ARCH}" != "s390x" ]; then \
curl -sLf https://github.com/rancher/k3s/releases/download/${CATTLE_K3S_VERSION}/k3s-images.txt -o /usr/tmp/k3s-images.txt; \
fi
ENV YQ_URL=https://github.com/mikefarah/yq/releases/download/3.4.1/yq_linux_${ARCH}
RUN curl -sLf ${YQ_URL} -o /usr/bin/yq && chmod +x /usr/bin/yq
RUN zypper install -y python3-tox python3-base python3 libffi-devel libopenssl-devel
ENV HELM_HOME /root/.helm
ENV DAPPER_ENV REPO TAG DRONE_TAG DRONE_COMMIT DRONE_BRANCH SYSTEM_CHART_DEFAULT_BRANCH FOSSA_API_KEY
ENV DAPPER_SOURCE /go/src/github.com/rancher/rancher/
ENV DAPPER_OUTPUT ./bin ./dist
ENV DAPPER_DOCKER_SOCKET true
ENV DAPPER_RUN_ARGS "-v rancher2-go16-pkg-1:/go/pkg -v rancher2-go16-cache-1:/root/.cache/go-build --privileged"
ENV TRASH_CACHE ${DAPPER_SOURCE}/.trash-cache
ENV GOCACHE /root/.cache/go-build
ENV HOME ${DAPPER_SOURCE}
VOLUME /var/lib/rancher
VOLUME /var/lib/kubelet
WORKDIR ${DAPPER_SOURCE}
ENTRYPOINT ["./scripts/entry"]
CMD ["ci"]