From cf744db5bfffd677fd3c9cdc9febacef5197f41c Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Tue, 2 Jan 2024 20:30:36 -0800 Subject: [PATCH] website: move to Fly Sadly I did this all once (and more completely) but then lost the commit. So this is a re-do. The sharing demo stuff isn't yet complete. Updates #1658 etc --- Dockerfile.website | 34 ++++++++++++++++++++++++++++++++++ Makefile | 9 +++++++++ fly.toml | 22 ++++++++++++++++++++++ website/pk-web/contributors.go | 8 +++++--- 4 files changed, 70 insertions(+), 3 deletions(-) create mode 100644 Dockerfile.website create mode 100644 fly.toml diff --git a/Dockerfile.website b/Dockerfile.website new file mode 100644 index 000000000..b64f14ce1 --- /dev/null +++ b/Dockerfile.website @@ -0,0 +1,34 @@ +FROM golang:1.21-bookworm AS build + +WORKDIR /go +RUN apt-get update && apt-get install -y --no-install-recommends \ + ca-certificates curl netbase wget git + +WORKDIR /perkeep +ADD go.mod . +ADD go.sum . + +RUN go version && go mod download + +ADD . . + +#RUN git fetch --unshallow || true + +RUN git log | git shortlog -sen > /perkeep-gitstats.txt + +RUN go build -o /bin/pk-web ./website/pk-web +#RUN go build -o /bin/perkeepd ./server/perkeepd + +FROM debian:bookworm + +COPY --from=build /bin/pk-web /bin/pk-web +#COPY --from=build /bin/perkeepd /bin/perkeepd +COPY --from=build /perkeep-gitstats.txt /perkeep-gitstats.txt + +ADD website /var/perkeep/website +ADD doc /var/perkeep/doc +ADD pkg /var/perkeep/pkg +ADD cmd /var/perkeep/cmd +ADD server /var/perkeep/server + +CMD ["/bin/pk-web", "--root=/var/perkeep/website", "--gitlog-file=/perkeep-gitstats.txt"] diff --git a/Makefile b/Makefile index 7e8e53ae6..79f626fb4 100644 --- a/Makefile +++ b/Makefile @@ -23,3 +23,12 @@ dockerbuilddev: dockerpushdev: dockerbuilddev docker push gcr.io/perkeep-containers/perkeep-dev-$(USER):latest + +webbuild: + docker build -t registry.fly.io/perkeep-website -f Dockerfile.website . + +web-push-prod: + flyctl deploy -a perkeep-website + +web-push-staging: + flyctl deploy -a perkeep-staging diff --git a/fly.toml b/fly.toml new file mode 100644 index 000000000..e3abd32dd --- /dev/null +++ b/fly.toml @@ -0,0 +1,22 @@ +app = "perkeep-website" + +[build] +dockerfile = "Dockerfile.website" + +[deploy] +strategy = "immediate" + +[[services]] + internal_port = 31798 + protocol = "tcp" + +[[services.ports]] + handlers = ["http"] + port = 80 + force_https = true # optional + +[[services.ports]] + handlers = ["tls", "http"] + port = "443" + + \ No newline at end of file diff --git a/website/pk-web/contributors.go b/website/pk-web/contributors.go index 492030ea3..9ade8afe2 100644 --- a/website/pk-web/contributors.go +++ b/website/pk-web/contributors.go @@ -75,7 +75,7 @@ func parseLine(l string) (name, email string, commits int, err error) { func gitShortlog() *exec.Cmd { if *shortLogFile != "" { - return exec.Command("/bin/bash", "-c", "cat", *shortLogFile) + return exec.Command("cat", *shortLogFile) } return exec.Command("/bin/bash", "-c", "git log | git shortlog -sen") } @@ -136,9 +136,11 @@ func genContribPage() ([]byte, error) { // Add URLs and roles for email, m := range urlsMap { a := byEmail[email] - if a != nil { - a.add(&m) + if a == nil { + log.Printf("skipping email %q", email) + continue } + a.add(&m) if len(m.Names) > 0 { a.Names = []string{m.Names[0]} }