Skip to content

Commit

Permalink
re-order Dockerfile; tweak for internal use
Browse files Browse the repository at this point in the history
  • Loading branch information
kphunter committed Aug 8, 2024
1 parent a9cc6d1 commit 21350b3
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# flyctl launch added from .gitignore
**/.idea
fly.toml
18 changes: 18 additions & 0 deletions .github/workflows/fly-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# See https://fly.io/docs/app-guides/continuous-deployment-with-github-actions/

name: Fly Deploy
on:
push:
branches:
- main
jobs:
deploy:
name: Deploy app
runs-on: ubuntu-latest
concurrency: deploy-group # optional: ensure only one action runs at a time
steps:
- uses: actions/checkout@v4
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy --remote-only
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
23 changes: 16 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
# Builder
FROM golang:1.19-alpine as builder

WORKDIR /app

COPY . ./

RUN go mod download
RUN go build


# Release
FROM alpine:latest
RUN apk update && apk add ca-certificates iptables ip6tables bash bind-tools jq && rm -rf /var/cache/apk/*

ENV TSFILE=tailscale_1.70.0_amd64.tgz
ENV DNSPROXYFILE=dnsproxy-linux-amd64-v0.72.1.tar.gz
ENV DNSPROXYVERSION=v0.72.1

WORKDIR /app
COPY . ./
ENV TSFILE=tailscale_1.30.2_amd64.tgz
ENV DNSPROXYFILE=dnsproxy-linux-amd64-v0.45.2.tar.gz
ENV DNSPROXYVERSION=v0.45.2

RUN apk update && apk add ca-certificates iptables ip6tables bash bind-tools jq && rm -rf /var/cache/apk/*
RUN wget https://pkgs.tailscale.com/stable/${TSFILE} && tar xzf ${TSFILE} --strip-components=1
RUN wget https://github.com/AdguardTeam/dnsproxy/releases/download/${DNSPROXYVERSION}/${DNSPROXYFILE} && tar xzf ${DNSPROXYFILE} --strip-components=1

COPY --from=builder /app/tailscale-router /app/tailscale-router
COPY . ./

# Copy and run tailscale init script, default nginx config
COPY docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
RUN mkdir -p /var/run/tailscale /var/cache/tailscale /var/lib/tailscale

CMD ["/app/start.sh"]
CMD ["/usr/local/bin/docker-entrypoint.sh"]
1 change: 0 additions & 1 deletion start.sh → docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ else
exit 1
fi


tail -f /dev/null
19 changes: 19 additions & 0 deletions fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# fly.toml app configuration file generated for bcit-ltc-subnet-router-crimson-sun-1032 on 2024-08-08T12:50:41-07:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = 'bcit-ltc-subnet-router'
primary_region = 'yyz'

[env]
TS_HOSTNAME = 'bcit-ltc-subnet-router'

[build]

[[vm]]
size = 'shared-cpu-1x'

[deploy]
# release_command = " tailscale down"
strategy = "canary"
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func main() {
}

fmt.Println("tailscale-router: running tailscale up")
upcmd := exec.Command("bash", "-c", fmt.Sprintf("%s up --authkey=%s --advertise-routes=%s", tailscale_binary_path, key, subnet))
upcmd := exec.Command("bash", "-c", fmt.Sprintf("%s up --authkey=%s --hostname=bcit-ltc-subnet-router --advertise-routes=%s", tailscale_binary_path, key, subnet))
err = upcmd.Run()
if err != nil {
panic(err)
Expand Down

0 comments on commit 21350b3

Please sign in to comment.