netmaker/docker/Dockerfile-netclient-multiarch-userspace
Peter Dave Hello 105b7dfc1c
Simplify and unify apk usage in Dockerfiles (#3407)
Replace `apk update` and `--update` flags with `--no-cache` across
Dockerfiles to improve consistency and eliminate unnecessary cache files.

This change reduces image size and ensures up-to-date package indices
without leaving temporary data. It also aligns with best practices
recommended for Alpine-based Docker images.
2025-04-30 02:55:34 +04:00

39 lines
991 B
Text

FROM gravitl/go-builder:latest as builder
# add glib support daemon manager
WORKDIR /app
COPY . .
ENV GO111MODULE=auto
RUN GOOS=linux CGO_ENABLED=0 /usr/local/go/bin/go build -ldflags="-w -s" -o netclient-app netclient/main.go
WORKDIR /root/
RUN apk add --no-cache git build-base libmnl-dev iptables
RUN git clone https://git.zx2c4.com/wireguard-go && \
cd wireguard-go && \
make && \
make install
ENV WITH_WGQUICK=yes
RUN git clone https://git.zx2c4.com/wireguard-tools && \
cd wireguard-tools && \
cd src && \
make && \
make install
FROM alpine:3.16.2
WORKDIR /root/
RUN apk add --no-cache bash libmnl gcompat iptables openresolv iproute2
COPY --from=builder /usr/bin/wireguard-go /usr/bin/wg* /usr/bin/
COPY --from=builder /app/netclient-app ./netclient
COPY --from=builder /app/scripts/netclient.sh .
RUN chmod 0755 netclient && chmod 0755 netclient.sh
ENV WG_QUICK_USERSPACE_IMPLEMENTATION=wireguard-go
ENTRYPOINT ["/bin/bash", "./netclient.sh"]