mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-06 03:46:02 +08:00
docker working
This commit is contained in:
parent
e2110d1402
commit
aac6837147
3 changed files with 41 additions and 19 deletions
|
@ -1,26 +1,39 @@
|
||||||
#first stage - builder
|
FROM gravitl/builder:latest as builder
|
||||||
|
# add glib support daemon manager
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
FROM golang:latest as builder
|
COPY . .
|
||||||
|
|
||||||
COPY . /app
|
|
||||||
|
|
||||||
WORKDIR /app/netclient
|
|
||||||
|
|
||||||
ENV GO111MODULE=auto
|
ENV GO111MODULE=auto
|
||||||
|
|
||||||
RUN CGO_ENABLED=0 GOOS=linux go build -o netclient main.go
|
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 /usr/local/go/bin/go build -ldflags="-w -s" -o netclient-app netclient/main.go
|
||||||
|
|
||||||
#second stage
|
|
||||||
|
|
||||||
FROM debian:latest
|
|
||||||
|
|
||||||
RUN apt-get update && apt-get -y install systemd procps
|
|
||||||
|
|
||||||
WORKDIR /root/
|
WORKDIR /root/
|
||||||
|
|
||||||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
RUN apk add --update git build-base libmnl-dev iptables
|
||||||
|
|
||||||
COPY --from=builder /app/netclient/netclient .
|
RUN git clone https://git.zx2c4.com/wireguard-go && \
|
||||||
|
cd wireguard-go && \
|
||||||
|
make && \
|
||||||
|
make install
|
||||||
|
|
||||||
CMD ["./netclient"]
|
ENV WITH_WGQUICK=yes
|
||||||
|
RUN git clone https://git.zx2c4.com/wireguard-tools && \
|
||||||
|
cd wireguard-tools && \
|
||||||
|
cd src && \
|
||||||
|
make && \
|
||||||
|
make install
|
||||||
|
|
||||||
|
FROM alpine:3.13.6
|
||||||
|
|
||||||
|
WORKDIR /root/
|
||||||
|
|
||||||
|
RUN apk add --no-cache --update bash libmnl 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/sh", "./netclient.sh"]
|
||||||
|
|
|
@ -21,6 +21,6 @@ FROM gravitl/netmaker:${NM_VERSION}
|
||||||
|
|
||||||
RUN apk add --no-cache --update bash libmnl iptables openresolv iproute2
|
RUN apk add --no-cache --update bash libmnl iptables openresolv iproute2
|
||||||
COPY --from=builder /usr/bin/wireguard-go /usr/bin/wg* /usr/bin/
|
COPY --from=builder /usr/bin/wireguard-go /usr/bin/wg* /usr/bin/
|
||||||
COPY scripts/userspace-entrypoint.sh ./entrypoint.sh
|
COPY scripts/netclient.sh ./entrypoint.sh
|
||||||
|
|
||||||
ENTRYPOINT ["/bin/sh", "./entrypoint.sh"]
|
ENTRYPOINT ["/bin/sh", "./entrypoint.sh"]
|
||||||
|
|
13
scripts/netclient.sh
Normal file → Executable file
13
scripts/netclient.sh
Normal file → Executable file
|
@ -1,13 +1,22 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
echo "[netclient] joining network"
|
echo "[netclient] joining network"
|
||||||
|
|
||||||
/etc/netclient/netclient join -t $NETCLIENT_ACCESSTOKEN -daemon off -dnson no
|
if [ -z "${SLEEP}" ]; then
|
||||||
|
SLEEP=10
|
||||||
|
fi
|
||||||
|
|
||||||
|
TOKEN_CMD=""
|
||||||
|
if [ "$TOKEN" != "" ]; then
|
||||||
|
TOKEN_CMD="-t $TOKEN"
|
||||||
|
fi
|
||||||
|
|
||||||
|
/root/netclient join $TOKEN_CMD -daemon off -dnson no
|
||||||
|
|
||||||
echo "[netclient] Starting netclient checkin"
|
echo "[netclient] Starting netclient checkin"
|
||||||
# loop and call checkin -n all
|
# loop and call checkin -n all
|
||||||
while [ 1 ]; do
|
while [ 1 ]; do
|
||||||
# add logs to netclient.logs
|
# add logs to netclient.logs
|
||||||
/etc/netclient/netclient checkin -n all
|
/root/netclient checkin -n all
|
||||||
sleep $SLEEP
|
sleep $SLEEP
|
||||||
done
|
done
|
||||||
echo "[netclient] exiting"
|
echo "[netclient] exiting"
|
||||||
|
|
Loading…
Add table
Reference in a new issue