-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tbr-bot: update for fly.io deployment
Support hosting on fly.io: - Switch configuration from command line flags to environment variables settable in fly.toml or via secrets as appropriate - add a Makefile and Dockerfile to build a container image - add an example fly.toml for deployment Signed-off-by: Denton Gentry <dgentry@tailscale.com>
- Loading branch information
1 parent
483764b
commit 2daad4e
Showing
8 changed files
with
175 additions
and
1,823 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
FROM golang:1.19.0-alpine3.16 as builder | ||
WORKDIR /app | ||
COPY go.mod go.sum ./ | ||
RUN go mod download | ||
COPY . ./ | ||
RUN go build | ||
|
||
|
||
FROM alpine:3.16 as tailscale | ||
WORKDIR /app | ||
ENV TSFILE=tailscale_1.28.0_amd64.tgz | ||
RUN wget https://pkgs.tailscale.com/stable/${TSFILE} && tar xzf ${TSFILE} --strip-components=1 | ||
|
||
|
||
# https://docs.docker.com/develop/develop-images/multistage-build/#use-multi-stage-builds | ||
FROM alpine:3.16 | ||
RUN apk update && apk add ca-certificates iptables ip6tables && rm -rf /var/cache/apk/* | ||
|
||
# Copy binary to production image | ||
COPY --from=builder /app/start.sh /start.sh | ||
COPY --from=builder /app/ToBeReviewedBot /ts-tbrbot | ||
COPY --from=tailscale /app/tailscaled /usr/local/bin/tailscaled | ||
COPY --from=tailscale /app/tailscale /usr/local/bin/tailscale | ||
RUN mkdir -p /var/run/tailscale /var/cache/tailscale /var/lib/tailscale | ||
|
||
# Run on container startup. | ||
CMD ["/start.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Build the Docker image and push to fly.io's container registry | ||
# Change $REGISTRY from ts-tbrbot to your fly.io app name and update | ||
# the [build] image in fly.toml to match. | ||
|
||
REGISTRY=registry.fly.io/ts-tbrbot:latest | ||
|
||
all: build | ||
|
||
build: | ||
docker build -t ${REGISTRY} . | ||
|
||
push: | ||
docker push ${REGISTRY} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Manually: | ||
# $ flyctl volumes create tbrbot_data --region sjc --size 1 | ||
# $ flyctl scale count 1 | ||
# $ flyctl secrets set TS_AUTHKEY=... TBRBOT_APP_ID=... TBRBOT_APP_INSTALL=... | ||
# $ flyctl secrets set TBRBOT_WEBHOOK_SECRET=... | ||
# $ flyctl secrets set TBRBOT_APP_PRIVATE_KEY=- < pem | ||
# $ flyctl ips allocate-v6 | ||
|
||
app = "example-tbrbot" | ||
kill_signal = "SIGINT" | ||
kill_timeout = 5 | ||
processes = [] | ||
|
||
[build] | ||
image = "registry.fly.io/ts-tbrbot:latest" | ||
|
||
[env] | ||
TBRBOT_APPNAME = "tbr-bot" | ||
TBRBOT_BUGREPO = "private" | ||
TBRBOT_ORG = "my-organization" | ||
TBRBOT_REPOS = "private,opensource" | ||
|
||
[experimental] | ||
allowed_public_ports = [] | ||
auto_rollback = true | ||
|
||
[mounts] | ||
destination = "/root" | ||
source = "tbrbot_data" | ||
|
||
[[services]] | ||
http_checks = [] | ||
internal_port = 8080 | ||
processes = ["app"] | ||
protocol = "tcp" | ||
script_checks = [] | ||
[services.concurrency] | ||
hard_limit = 25 | ||
soft_limit = 20 | ||
type = "connections" | ||
|
||
[[services.ports]] | ||
force_https = true | ||
handlers = ["http"] | ||
port = 80 | ||
|
||
[[services.ports]] | ||
handlers = ["tls", "http"] | ||
port = 443 | ||
|
||
[[services.tcp_checks]] | ||
grace_period = "1s" | ||
interval = "15s" | ||
restart_limit = 0 | ||
timeout = "2s" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module github.com/tailscale/tbr-audit | ||
module github.com/tailscale/ToBeReviewedBot | ||
|
||
go 1.19 | ||
|
||
|
Oops, something went wrong.