# Builder image FROM docker.io/golang:1.20-bullseye AS build ARG VERSION=v0.22.3 ARG CADDY_VERSION=v2.7.6 ENV GOPATH /go RUN apt-get install -y git && \ git clone https://github.com/juanfont/headscale -b $VERSION /go/src/headscale && \ git clone https://github.com/caddyserver/caddy.git -b $CADDY_VERSION /go/src/caddy WORKDIR /go/src/headscale RUN go mod download RUN CGO_ENABLED=0 GOOS=linux go install -tags ts2019 -ldflags="-s -w -X github.com/juanfont/headscale/cmd/headscale/cli.Version=$VERSION" -a ./cmd/headscale RUN strip /go/bin/headscale RUN test -e /go/bin/headscale # Caddy build WORKDIR /go/src/caddy RUN go mod download RUN GOOS=linux go install ./cmd/caddy RUN strip /go/bin/caddy RUN test -e /go/bin/caddy # Node build image FROM docker.io/node:19-bullseye AS build-node ARG UI_COMMIT=a9db179089e3ae2b417fb657a2d3da68a54b1f2d RUN apt-get install -y git && \ git clone https://github.com/gurucomputing/headscale-ui /headscale-ui WORKDIR /headscale-ui RUN git checkout $UI_COMMIT && npm install --development && npm run build # Production image # Note that we do not use "distroless" because we actually want to have a shell in the image # to run app.sh (in order to perform custom initialization) FROM docker.io/golang:1.20-bullseye COPY --from=build /go/bin/headscale /bin/headscale COPY --from=build /go/bin/caddy /bin/caddy COPY --from=build-node /headscale-ui/build /srv/web ADD Caddyfile /etc/ ENV TZ UTC ADD app.sh / RUN chmod +x /app.sh EXPOSE 8080/tcp # State path # Note that configuration should be mounted or added in /etc/headscale VOLUME /var/lib/headscale CMD ["/app.sh"]