headscale: refactor container to include headscale-ui

fly.io now charges for dedicated IP. gRPC requires a dedicated port (or
a lot of fiddling), so let's just use headscale-ui from now on.
This commit is contained in:
Peter Cai 2024-01-29 22:11:24 -05:00
parent 7f3de6a004
commit 197adfeddb
3 changed files with 39 additions and 1 deletions

11
headscale/Caddyfile Normal file
View file

@ -0,0 +1,11 @@
:8080 {
root * /srv
handle /web* {
file_server
}
handle {
reverse_proxy * http://127.0.0.1:8081
}
}

View file

@ -1,10 +1,12 @@
# 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/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
@ -14,12 +16,35 @@ RUN CGO_ENABLED=0 GOOS=linux go install -tags ts2019 -ldflags="-s -w -X github.c
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 /

View file

@ -3,4 +3,6 @@
touch /var/lib/headscale/db.sqlite
mkdir /var/lib/headscale/.cache
mkdir -p /var/run/headscale
caddy run --config /etc/Caddyfile &
exec headscale -c /etc/headscale/config.yaml serve