Skip to content

Commit

Permalink
Allow configuring the tsnet state directory. Automatically configure …
Browse files Browse the repository at this point in the history
…it to be /data in the Dockerfile
  • Loading branch information
giodamelio committed Apr 25, 2023
1 parent 4dc9517 commit 7fb7b59
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,10 @@ ADD https://github.com/giodamelio/tailscale-custom-domain-dns/releases/download/

RUN tar xzvf ${RELEASE_FILE} && rm ${RELEASE_FILE}

# Create empty config file so the cli doesn't complain
RUN mkdir /root/.config/ && touch /root/.config/tailscale-custom-domain-dns.toml

# Save the state directory in /data so it can be added to a volume easily
ENV TSDNS_TAILSCALE_STATEDIRECTORY=/data

ENTRYPOINT [ "/srv/tailscale-custom-domain-dns" ]
5 changes: 5 additions & 0 deletions examples/tailscale-custom-domain-dns.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ oauth-client-secret = ""
# The hostname that the server will connect to your tailnet with.
hostname = "tailscale-custom-domain-dns"

# The directory that the Tailscale state is stored in
# If it is not set, tsnet will choose a path in the users config directory
# Example: state-dir = "/data"
state-dir = ""

[dns-server]
# The port that the DNS server will run on.
# The port is opened directly on your tailnet using the tsnet library, so you
Expand Down
3 changes: 3 additions & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ func Start() {
tsServer := new(tsnet.Server)
tsServer.Hostname = viper.GetString("tailscale.hostname")
tsServer.AuthKey = viper.GetString("tailscale.auth-key")
if viper.IsSet("tailscale.state-directory") {
tsServer.Dir = viper.GetString("tailscale.state-directory")
}
tsServer.Logf = func(format string, args ...any) {
log.
Trace().
Expand Down

0 comments on commit 7fb7b59

Please sign in to comment.