Skip to content

Commit a7e9989

Browse files
committed
final touches before easy install.
1 parent 991ddc5 commit a7e9989

7 files changed

Lines changed: 78 additions & 93 deletions

File tree

.github/workflows/go.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 20 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,32 @@
1-
name: build for all platforms
1+
name: build and release
22

33
on:
4-
release:
5-
types: [created]
4+
push:
5+
tags:
6+
- '*'
67

78
permissions:
89
contents: write
910

1011
jobs:
11-
12-
releases-matrix:
12+
build-and-release:
1313
name: Build and release binary
1414
runs-on: ubuntu-latest
15-
strategy:
16-
matrix:
17-
goos: [linux]
18-
goarch: [amd64]
19-
exclude:
20-
- goarch: arm64
21-
goos: windows
22-
steps:
23-
- uses: actions/checkout@v3
24-
- uses: wangyoucao577/go-release-action@v1.40
25-
with:
26-
github_token: ${{ secrets.GITHUB_TOKEN }}
27-
goos: ${{ matrix.goos }}
28-
goarch: ${{ matrix.goarch }}
29-
overwrite: true
30-
md5sum: false
31-
sha256sum: false
32-
compress_assets: false
33-
34-
release-docker:
35-
name: Push Docker image to Docker Hub
36-
runs-on: ubuntu-latest
3715
steps:
38-
- name: Check out the repo
39-
uses: actions/checkout@v4
40-
41-
- name: Log in to Docker Hub
42-
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
16+
- uses: actions/checkout@v4
17+
- uses: actions/setup-go@v4
4318
with:
44-
username: ${{ secrets.DOCKER_USERNAME }}
45-
password: ${{ secrets.DOCKER_PASSWORD }}
46-
47-
- name: Extract metadata (tags, labels) for Docker
48-
id: meta
49-
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
19+
go-version: '1.25'
20+
- name: Install musl and musl-gcc
21+
run: sudo apt-get update && sudo apt-get install -y musl-tools
22+
- name: Get templ version
23+
run: echo "TEMPL_VERSION=$(grep 'github.com/a-h/templ' go.mod | awk '{print $2}')" >> $GITHUB_ENV
24+
- name: Install templ
25+
run: go install github.com/a-h/templ/cmd/templ@${{ env.TEMPL_VERSION }}
26+
- uses: extractions/setup-just@v2
27+
- name: Build binary
28+
run: just build
29+
- name: Create release
30+
uses: softprops/action-gh-release@v2
5031
with:
51-
images: tijlxyz/khatru-pyramid
52-
53-
- name: Build and push Docker image
54-
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
55-
with:
56-
context: .
57-
file: ./Dockerfile
58-
push: true
59-
tags: ${{ steps.meta.outputs.tags }}
60-
labels: ${{ steps.meta.outputs.labels }}
61-
32+
files: pyramid-exe

curation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func processReactions(ctx context.Context, event nostr.Event) {
5353
}
5454

5555
popularThreshold := min(2, (totalMembers*global.Settings.Popular.PercentThreshold)/100)
56-
uppermostThreshold := min(2, (totalMembers*global.Settings.Uppermost.PercentThreshold)/100)
56+
uppermostThreshold := min(3, (totalMembers*global.Settings.Uppermost.PercentThreshold)/100)
5757

5858
// for all events we meet the popular threshold for
5959
for target, votes := range popularVotes {

go.mod

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
module github.com/fiatjaf/pyramid
22

3-
go 1.24.2
3+
go 1.25
44

55
require (
6-
fiatjaf.com/nostr v0.0.0-20251031160519-32bbff615a04
6+
fiatjaf.com/nostr v0.0.0-20251126120447-7261a4b515ed
77
github.com/FastFilter/xorfilter v0.2.1
88
github.com/a-h/templ v0.3.960
99
github.com/kelseyhightower/envconfig v1.4.0
@@ -60,5 +60,3 @@ require (
6060
golang.org/x/text v0.27.0 // indirect
6161
gopkg.in/yaml.v3 v3.0.1 // indirect
6262
)
63-
64-
replace fiatjaf.com/nostr => ../nostrlib

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
fiatjaf.com/nostr v0.0.0-20251126120447-7261a4b515ed h1:dip4Bxlfj4/N2oIIGCZpcYRrvfMObcXRcyBM5uYswnM=
2+
fiatjaf.com/nostr v0.0.0-20251126120447-7261a4b515ed/go.mod h1:ue7yw0zHfZj23Ml2kVSdBx0ENEaZiuvGxs/8VEN93FU=
13
github.com/FastFilter/xorfilter v0.2.1 h1:lbdeLG9BdpquK64ZsleBS8B4xO/QW1IM0gMzF7KaBKc=
24
github.com/FastFilter/xorfilter v0.2.1/go.mod h1:aumvdkhscz6YBZF9ZA/6O4fIoNod4YR50kIVGGZ7l9I=
35
github.com/ImVexed/fasturl v0.0.0-20230304231329-4e41488060f3 h1:ClzzXMDDuUbWfNNZqGeYq4PnYOlwlOVIvSyNaIy0ykg=

handler.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ func settingsHandler(w http.ResponseWriter, r *http.Request) {
107107
moderated.Relay.ServiceURL = global.Settings.WSScheme() + global.Settings.Domain + "/" + global.Settings.Moderated.HTTPBasePath
108108
popular.Relay.ServiceURL = global.Settings.WSScheme() + global.Settings.Domain + "/" + global.Settings.Popular.HTTPBasePath
109109
uppermost.Relay.ServiceURL = global.Settings.WSScheme() + global.Settings.Domain + "/" + global.Settings.Uppermost.HTTPBasePath
110+
go restartSoon()
110111
//
111112
// theme settings
112113
case "background_color":
@@ -428,6 +429,7 @@ func domainSetupHandler(w http.ResponseWriter, r *http.Request) {
428429
return
429430
}
430431

432+
go restartSoon()
431433
http.Redirect(w, r, "/", 302)
432434
return
433435
}

main.go

Lines changed: 51 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,16 @@ func run(ctx context.Context) error {
360360

361361
mux.Handle("/", relay)
362362

363+
g, ctx := errgroup.WithContext(ctx)
364+
365+
if global.S.Port == "443" {
366+
// if we don't have a domain name we'll listen only on port 80 without doing the autocert dance yet
367+
if global.Settings.Domain == "" {
368+
log.Info().Msg("no domain setup yet, running only on port 80 for now")
369+
global.S.Port = "80"
370+
}
371+
}
372+
363373
server := &http.Server{
364374
Addr: global.S.Host + ":" + global.S.Port,
365375
Handler: ipBlockMiddleware(setupCheckMiddleware(mux)),
@@ -368,33 +378,57 @@ func run(ctx context.Context) error {
368378
},
369379
}
370380

371-
var listenFunc func() error
372381
if global.S.Port == "443" {
373382
manager := &autocert.Manager{
374383
Prompt: func(_ string) bool { return true },
375384
HostPolicy: autocert.HostWhitelist(global.Settings.Domain),
376385
Cache: autocert.DirCache("certs"),
377386
}
378-
server.TLSConfig = manager.TLSConfig()
379-
listenFunc = func() error { return server.ListenAndServeTLS("", "") }
380-
log.Info().Msg("running on https://" + global.S.Host + ":" + global.S.Port)
387+
388+
// HTTP server on 80 for ACME challenges and user access
389+
httpServer := &http.Server{
390+
Addr: global.S.Host + ":80",
391+
Handler: manager.HTTPHandler(mux),
392+
BaseContext: func(_ net.Listener) context.Context {
393+
return ctx
394+
},
395+
}
396+
g.Go(func() error { return httpServer.ListenAndServe() })
397+
398+
// HTTPS server on 443
399+
httpsServer := &http.Server{
400+
Addr: global.S.Host + ":443",
401+
Handler: ipBlockMiddleware(mux),
402+
BaseContext: func(_ net.Listener) context.Context {
403+
return ctx
404+
},
405+
}
406+
httpsServer.TLSConfig = manager.TLSConfig()
407+
408+
g.Go(func() error { return httpsServer.ListenAndServeTLS("", "") })
409+
log.Info().Msg("running on https://" + global.S.Host + ":443 and http://" + global.S.Host + ":80")
410+
g.Go(func() error {
411+
<-ctx.Done()
412+
httpsServer.Shutdown(context.Background())
413+
httpServer.Shutdown(context.Background())
414+
return nil
415+
})
381416
} else {
382-
listenFunc = server.ListenAndServe
417+
g.Go(server.ListenAndServe)
383418
log.Info().Msg("running on http://" + global.S.Host + ":" + global.S.Port)
419+
420+
g.Go(func() error {
421+
<-ctx.Done()
422+
if err := server.Shutdown(context.Background()); err != nil {
423+
return err
424+
}
425+
if err := server.Close(); err != nil {
426+
return err
427+
}
428+
return nil
429+
})
384430
}
385431

386-
g, ctx := errgroup.WithContext(ctx)
387-
g.Go(listenFunc)
388-
g.Go(func() error {
389-
<-ctx.Done()
390-
if err := server.Shutdown(context.Background()); err != nil {
391-
return err
392-
}
393-
if err := server.Close(); err != nil {
394-
return err
395-
}
396-
return nil
397-
})
398432
return g.Wait()
399433
}
400434

0 commit comments

Comments
 (0)