Skip to content

Commit 6997e94

Browse files
committed
fix: wireguard-go build
1 parent de96cea commit 6997e94

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
lines changed

build/liqo/Dockerfile

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,36 @@ FROM alpine:3.20
44
ARG COMPONENT
55
ARG TARGETARCH
66

7+
RUN if [ "$COMPONENT" = "geneve" ] || [ "$COMPONENT" = "wireguard" ] || [ "$COMPONENT" = "gateway" ]; then \
8+
set -x; \
9+
apk add --no-cache iproute2 nftables bash wireguard-tools tcpdump conntrack-tools curl iputils; \
10+
fi
11+
12+
RUN if [ "$COMPONENT" = "wireguard" ]; then \
13+
set -e; \
14+
apk add --no-cache git curl; \
15+
GO_VERSION=1.22.4; \
16+
# Map Docker TARGETARCH to Go architecture names \
17+
case "$TARGETARCH" in \
18+
amd64) GO_ARCH=amd64 ;; \
19+
arm64) GO_ARCH=arm64 ;; \
20+
arm) GO_ARCH=armv6l ;; \
21+
*) echo "Unsupported architecture: $TARGETARCH" && exit 1 ;; \
22+
esac; \
23+
curl -L https://go.dev/dl/go${GO_VERSION}.linux-${GO_ARCH}.tar.gz | tar -C /usr/local -xz; \
24+
export PATH="/usr/local/go/bin:$PATH"; \
25+
git clone https://git.zx2c4.com/wireguard-go; cd wireguard-go; git checkout f333402bd9cbe0f3eeb02507bd14e23d7d639280; \
26+
CGO_ENABLED=0 GOOS=linux GOARCH=$TARGETARCH /usr/local/go/bin/go build -ldflags="-s -w" -o /usr/bin/wireguard-go; \
27+
cd .. && rm -rf wireguard-go; \
28+
rm -rf /usr/local/go; \
29+
apk del git curl; \
30+
fi
31+
732
# Copy the correct binary for the architecture
833
COPY ./bin/${TARGETARCH}/${COMPONENT}_linux_${TARGETARCH} /usr/bin/${COMPONENT}
934
RUN chmod +x /usr/bin/${COMPONENT}
1035
RUN ln -s /usr/bin/${COMPONENT} /usr/bin/liqo-component
1136

12-
RUN if [ "$COMPONENT" = "geneve" ] || [ "$COMPONENT" = "wireguard" ] || [ "$COMPONENT" = "gateway" ]; then \
13-
apk add --no-cache iproute2 nftables bash wireguard-tools tcpdump conntrack-tools curl iputils; \
14-
fi
15-
1637
WORKDIR /workspace
1738

1839
ENTRYPOINT ["/usr/bin/liqo-component"]

build/liqo/build.sh

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,8 @@ set -e
44
set -o nounset
55
set -o pipefail
66

7-
usage() {
8-
echo "Usage: $0 [-m] [-p] <component-folder>"
9-
echo " -p Push the built image to the registry"
10-
echo " -h Show this help message"
11-
}
12-
137
if [ $# -ne 1 ]; then
14-
usage
8+
echo "Usage: $0 <component-folder>"
159
exit 1
1610
fi
1711

0 commit comments

Comments
 (0)