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
This commit is contained in:
Brad Fitzpatrick 2024-01-02 20:30:36 -08:00
parent e1a04f92ed
commit cf744db5bf
4 changed files with 70 additions and 3 deletions

34
Dockerfile.website Normal file
View File

@ -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"]

View File

@ -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

22
fly.toml Normal file
View File

@ -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"

View File

@ -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]}
}