Skip to content

Commit a72809b

Browse files
authored
Merge pull request nicolaka#52 from sean-abbott/master
Add a multi-arch build so that this can be used from RPi based kubernetes
2 parents 817812f + d1b1129 commit a72809b

File tree

3 files changed

+101
-9
lines changed

3 files changed

+101
-9
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: buildx
2+
3+
on:
4+
pull_request:
5+
branches: master
6+
push:
7+
branches: master
8+
tags:
9+
10+
jobs:
11+
buildx:
12+
runs-on: ubuntu-latest
13+
steps:
14+
-
15+
name: Checkout
16+
uses: actions/checkout@v2
17+
-
18+
name: Set up Docker Buildx
19+
id: buildx
20+
uses: crazy-max/ghaction-docker-buildx@v3
21+
with:
22+
buildx-version: latest
23+
qemu-version: latest
24+
-
25+
name: Available platforms
26+
run: echo ${{ steps.buildx.outputs.platforms }}
27+
-
28+
name: Run Buildx
29+
run: |
30+
docker buildx build \
31+
--platform linux/amd64,linux/arm64 \
32+
--output "type=image,push=false" \
33+
--file ./Dockerfile .

Dockerfile

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
FROM debian:stable-slim as fetcher
2+
COPY build/fetch_binaries.sh /tmp/fetch_binaries.sh
3+
4+
RUN apt-get update && apt-get install -y \
5+
curl \
6+
wget
7+
8+
RUN /tmp/fetch_binaries.sh
9+
110
FROM alpine:3.11
211

312
RUN set -ex \
@@ -56,19 +65,13 @@ RUN set -ex \
5665
RUN mv /usr/sbin/tcpdump /usr/bin/tcpdump
5766

5867
# Installing ctop - top-like container monitor
59-
RUN wget https://github.com/bcicen/ctop/releases/download/v0.7.1/ctop-0.7.1-linux-amd64 -O /usr/local/bin/ctop && chmod +x /usr/local/bin/ctop
68+
COPY --from=fetcher /tmp/ctop /usr/local/bin/ctop
6069

6170
# Installing calicoctl
62-
ARG CALICOCTL_VERSION=v3.13.3
63-
RUN wget https://github.com/projectcalico/calicoctl/releases/download/${CALICOCTL_VERSION}/calicoctl && chmod +x calicoctl && mv calicoctl /usr/local/bin
71+
COPY --from=fetcher /tmp/calicoctl /usr/local/bin/calicoctl
6472

6573
# Installing termshark
66-
ENV TERMSHARK_VERSION 2.1.1
67-
RUN wget https://github.com/gcla/termshark/releases/download/v${TERMSHARK_VERSION}/termshark_${TERMSHARK_VERSION}_linux_x64.tar.gz -O /tmp/termshark_${TERMSHARK_VERSION}_linux_x64.tar.gz && \
68-
tar -zxvf /tmp/termshark_${TERMSHARK_VERSION}_linux_x64.tar.gz && \
69-
mv termshark_${TERMSHARK_VERSION}_linux_x64/termshark /usr/local/bin/termshark && \
70-
chmod +x /usr/local/bin/termshark
71-
74+
COPY --from=fetcher /tmp/termshark /usr/local/bin/termshark
7275

7376
# Settings
7477
ADD motd /etc/motd

build/fetch_binaries.sh

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
get_latest_release() {
5+
curl --silent "https://api.github.com/repos/$1/releases/latest" | # Get latest release from GitHub api
6+
grep '"tag_name":' | # Get tag line
7+
sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value
8+
}
9+
10+
11+
ARCH=$(uname -m)
12+
case $ARCH in
13+
x86_64)
14+
ARCH=amd64
15+
;;
16+
aarch64)
17+
ARCH=arm64
18+
;;
19+
esac
20+
21+
get_ctop() {
22+
VERSION=$(get_latest_release bcicen/ctop | sed -e 's/^v//')
23+
LINK="https://github.com/bcicen/ctop/releases/download/v${VERSION}/ctop-${VERSION}-linux-${ARCH}"
24+
wget "$LINK" -O /tmp/ctop && chmod +x /tmp/ctop
25+
}
26+
27+
get_calicoctl() {
28+
VERSION=$(get_latest_release projectcalico/calicoctl)
29+
LINK="https://github.com/projectcalico/calicoctl/releases/download/${VERSION}/calicoctl-linux-${ARCH}"
30+
wget "$LINK" -O /tmp/calicoctl && chmod +x /tmp/calicoctl
31+
}
32+
33+
get_termshark() {
34+
case "$ARCH" in
35+
"arm"*)
36+
echo "echo termshark does not yet support arm" > /tmp/termshark && chmod +x /tmp/termshark
37+
;;
38+
*)
39+
VERSION=$(get_latest_release gcla/termshark | sed -e 's/^v//')
40+
if [ "$ARCH" == "amd64" ]; then
41+
TERM_ARCH=x64
42+
else
43+
TERM_ARCH="$ARCH"
44+
fi
45+
LINK="https://github.com/gcla/termshark/releases/download/v${VERSION}/termshark_${VERSION}_linux_${TERM_ARCH}.tar.gz"
46+
wget "$LINK" -O /tmp/termshark.tar.gz && \
47+
tar -zxvf /tmp/termshark.tar.gz && \
48+
mv "termshark_${VERSION}_linux_${TERM_ARCH}/termshark" /tmp/termshark && \
49+
chmod +x /tmp/termshark
50+
;;
51+
esac
52+
}
53+
54+
get_ctop
55+
get_calicoctl
56+
get_termshark

0 commit comments

Comments
 (0)