repos / pico

pico services - prose.sh, pastes.sh, imgs.sh, feeds.sh, pgs.sh
git clone https://github.com/picosh/pico.git

commit
8dfc7cc
parent
88726f8
author
Antonio Mika
date
2024-10-11 15:49:58 +0000 UTC
Refactor pubsub->pipe
23 files changed,  +80, -80
M .env.example
+16, -16
 1@@ -146,19 +146,19 @@ AUTH_DOMAIN=http://auth.dev.pico.sh:3006
 2 AUTH_ISSUER=pico.sh
 3 AUTH_WEB_PORT=3000
 4 
 5-PUBSUB_CADDYFILE=./caddy/Caddyfile
 6-PUBSUB_V4=
 7-PUBSUB_V6=
 8-PUBSUB_HTTP_V4=$PUBSUB_V4:80
 9-PUBSUB_HTTP_V6=[$PUBSUB_V6]:80
10-PUBSUB_HTTPS_V4=$PUBSUB_V4:443
11-PUBSUB_HTTPS_V6=[$PUBSUB_V6]:443
12-PUBSUB_SSH_V4=$PUBSUB_V4:22
13-PUBSUB_SSH_V6=[$PUBSUB_V6]:22
14-PUBSUB_HOST=
15-PUBSUB_SSH_PORT=2222
16-PUBSUB_WEB_PORT=3000
17-PUBSUB_PROM_PORT=9222
18-PUBSUB_DOMAIN=pubsub.dev.pico.sh:3001
19-PUBSUB_PROTOCOL=http
20-PUBSUB_DEBUG=1
21+PIPE_CADDYFILE=./caddy/Caddyfile
22+PIPE_V4=
23+PIPE_V6=
24+PIPE_HTTP_V4=$PIPE_V4:80
25+PIPE_HTTP_V6=[$PIPE_V6]:80
26+PIPE_HTTPS_V4=$PIPE_V4:443
27+PIPE_HTTPS_V6=[$PIPE_V6]:443
28+PIPE_SSH_V4=$PIPE_V4:22
29+PIPE_SSH_V6=[$PIPE_V6]:22
30+PIPE_HOST=
31+PIPE_SSH_PORT=2222
32+PIPE_WEB_PORT=3000
33+PIPE_PROM_PORT=9222
34+PIPE_DOMAIN=pipe.dev.pico.sh:3001
35+PIPE_PROTOCOL=http
36+PIPE_DEBUG=1
M .github/workflows/build.yml
+1, -1
1@@ -41,7 +41,7 @@ jobs:
2     needs: test
3     strategy:
4       matrix:
5-        APP: [prose, pastes, imgs, pgs, feeds, pubsub]
6+        APP: [prose, pastes, imgs, pgs, feeds, pipe]
7     steps:
8     - name: Checkout repo
9       uses: actions/checkout@v3
M Makefile
+2, -2
 1@@ -58,7 +58,7 @@ bp-%: bp-setup
 2 	$(DOCKER_BUILDX_BUILD) --build-arg "APP=$*" -t "ghcr.io/picosh/pico/$*-web:$(DOCKER_TAG)" --target release-web .
 3 .PHONY: bp-%
 4 
 5-bp-all: bp-prose bp-pastes bp-imgs bp-feeds bp-pgs bp-auth bp-bouncer bp-pubsub
 6+bp-all: bp-prose bp-pastes bp-imgs bp-feeds bp-pgs bp-auth bp-bouncer bp-pipe
 7 .PHONY: bp-all
 8 
 9 build-auth:
10@@ -74,7 +74,7 @@ build-%:
11 	go build -o "build/$*-ssh" "./cmd/$*/ssh"
12 .PHONY: build-%
13 
14-build: build-prose build-pastes build-imgs build-feeds build-pgs build-auth build-pico build-pubsub
15+build: build-prose build-pastes build-imgs build-feeds build-pgs build-auth build-pico build-pipe
16 .PHONY: build
17 
18 store-clean:
A cmd/pipe/ssh/main.go
+7, -0
1@@ -0,0 +1,7 @@
2+package main
3+
4+import "github.com/picosh/pico/pipe"
5+
6+func main() {
7+	pipe.StartSshServer()
8+}
A cmd/pipe/web/main.go
+7, -0
1@@ -0,0 +1,7 @@
2+package main
3+
4+import "github.com/picosh/pico/pipe"
5+
6+func main() {
7+	pipe.StartApiServer()
8+}
D cmd/pubsub/ssh/main.go
+0, -7
1@@ -1,7 +0,0 @@
2-package main
3-
4-import "github.com/picosh/pico/pubsub"
5-
6-func main() {
7-	pubsub.StartSshServer()
8-}
D cmd/pubsub/web/main.go
+0, -7
1@@ -1,7 +0,0 @@
2-package main
3-
4-import "github.com/picosh/pico/pubsub"
5-
6-func main() {
7-	pubsub.StartApiServer()
8-}
M docker-compose.override.yml
+5, -5
 1@@ -45,24 +45,24 @@ services:
 2       - ./data/pastes-ssh/data:/app/ssh_data
 3     ports:
 4       - "2221:2222"
 5-  pubsub-web:
 6+  pipe-web:
 7     build:
 8       args:
 9-        APP: pubsub
10+        APP: pipe
11       target: release-web
12     env_file:
13       - .env.example
14     ports:
15       - "3001:3000"
16-  pubsub-ssh:
17+  pipe-ssh:
18     build:
19       args:
20-        APP: pubsub
21+        APP: pipe
22       target: release-ssh
23     env_file:
24       - .env.example
25     volumes:
26-      - ./data/pubsub-ssh/data:/app/ssh_data
27+      - ./data/pipe-ssh/data:/app/ssh_data
28     ports:
29       - "2221:2222"
30   prose-web:
M docker-compose.prod.yml
+22, -22
 1@@ -88,50 +88,50 @@ services:
 2     ports:
 3       - "${PASTES_SSH_V4:-22}:2222"
 4       - "${PASTES_SSH_V6:-[::1]:22}:2222"
 5-  pubsub-caddy:
 6+  pipe-caddy:
 7     image: ghcr.io/picosh/pico/caddy:latest
 8     restart: always
 9     networks:
10-      - pubsub
11+      - pipe
12     env_file:
13       - .env.prod
14     environment:
15-      APP_DOMAIN: ${PUBSUB_DOMAIN:-pipe.pico.sh}
16-      APP_EMAIL: ${PUBSUB_EMAIL:-hello@pico.sh}
17+      APP_DOMAIN: ${PIPE_DOMAIN:-pipe.pico.sh}
18+      APP_EMAIL: ${PIPE_EMAIL:-hello@pico.sh}
19     volumes:
20-      - ${PUBSUB_CADDYFILE}:/etc/caddy/Caddyfile
21-      - ./data/pubsub-caddy/data:/data
22-      - ./data/pubsub-caddy/config:/config
23+      - ${PIPE_CADDYFILE}:/etc/caddy/Caddyfile
24+      - ./data/pipe-caddy/data:/data
25+      - ./data/pipe-caddy/config:/config
26     ports:
27-      - "${PUBSUB_HTTPS_V4:-443}:443"
28-      - "${PUBSUB_HTTP_V4:-80}:80"
29-      - "${PUBSUB_HTTPS_V6:-[::1]:443}:443"
30-      - "${PUBSUB_HTTP_V6:-[::1]:80}:80"
31+      - "${PIPE_HTTPS_V4:-443}:443"
32+      - "${PIPE_HTTP_V4:-80}:80"
33+      - "${PIPE_HTTPS_V6:-[::1]:443}:443"
34+      - "${PIPE_HTTP_V6:-[::1]:80}:80"
35     profiles:
36-      - pubsub
37+      - pipe
38       - caddy
39       - all
40-  pubsub-web:
41+  pipe-web:
42     networks:
43-      pubsub:
44+      pipe:
45         aliases:
46           - web
47     env_file:
48       - .env.prod
49     volumes:
50-      - ./data/pubsub-ssh/data:/app/ssh_data
51-  pubsub-ssh:
52+      - ./data/pipe-ssh/data:/app/ssh_data
53+  pipe-ssh:
54     networks:
55-      pubsub:
56+      pipe:
57         aliases:
58           - ssh
59     env_file:
60       - .env.prod
61     volumes:
62-      - ./data/pubsub-ssh/data:/app/ssh_data
63+      - ./data/pipe-ssh/data:/app/ssh_data
64     ports:
65-      - "${PUBSUB_SSH_V4:-22}:2222"
66-      - "${PUBSUB_SSH_V6:-[::1]:22}:2222"
67+      - "${PIPE_SSH_V4:-22}:2222"
68+      - "${PIPE_SSH_V6:-[::1]:22}:2222"
69   prose-caddy:
70     image: ghcr.io/picosh/pico/caddy:latest
71     restart: always
72@@ -396,9 +396,9 @@ networks:
73     ipam:
74       config:
75         - subnet: 172.25.0.0/16
76-  pubsub:
77+  pipe:
78     driver_opts:
79-      com.docker.network.bridge.name: pubsub
80+      com.docker.network.bridge.name: pipe
81     ipam:
82       config:
83         - subnet: 172.27.0.0/16
M docker-compose.yml
+6, -6
 1@@ -43,18 +43,18 @@ services:
 2       - pastes
 3       - services
 4       - all
 5-  pubsub-web:
 6-    image: ghcr.io/picosh/pico/pubsub-web:latest
 7+  pipe-web:
 8+    image: ghcr.io/picosh/pico/pipe-web:latest
 9     restart: always
10     profiles:
11-      - pubsub
12+      - pipe
13       - services
14       - all
15-  pubsub-ssh:
16-    image: ghcr.io/picosh/pico/pubsub-ssh:latest
17+  pipe-ssh:
18+    image: ghcr.io/picosh/pico/pipe-ssh:latest
19     restart: always
20     profiles:
21-      - pubsub
22+      - pipe
23       - services
24       - all
25   prose-web:
R pubsub/api.go => pipe/api.go
+1, -1
1@@ -1,4 +1,4 @@
2-package pubsub
3+package pipe
4 
5 import (
6 	"fmt"
R pubsub/cli.go => pipe/cli.go
+1, -1
1@@ -1,4 +1,4 @@
2-package pubsub
3+package pipe
4 
5 import (
6 	"bytes"
R pubsub/config.go => pipe/config.go
+6, -6
 1@@ -1,4 +1,4 @@
 2-package pubsub
 3+package pipe
 4 
 5 import (
 6 	"github.com/picosh/pico/shared"
 7@@ -6,17 +6,17 @@ import (
 8 )
 9 
10 func NewConfigSite() *shared.ConfigSite {
11-	domain := utils.GetEnv("PUBSUB_DOMAIN", "pipe.pico.sh")
12-	port := utils.GetEnv("PUBSUB_WEB_PORT", "3000")
13+	domain := utils.GetEnv("PIPE_DOMAIN", "pipe.pico.sh")
14+	port := utils.GetEnv("PIPE_WEB_PORT", "3000")
15 	dbURL := utils.GetEnv("DATABASE_URL", "")
16-	protocol := utils.GetEnv("PUBSUB_PROTOCOL", "https")
17+	protocol := utils.GetEnv("PIPE_PROTOCOL", "https")
18 
19 	return &shared.ConfigSite{
20 		Domain:   domain,
21 		Port:     port,
22 		Protocol: protocol,
23 		DbURL:    dbURL,
24-		Logger:   shared.CreateLogger("pubsub"),
25-		Space:    "pubsub",
26+		Logger:   shared.CreateLogger("pipe"),
27+		Space:    "pipe",
28 	}
29 }
R pubsub/html/base.layout.tmpl => pipe/html/base.layout.tmpl
+0, -0
R pubsub/html/footer.partial.tmpl => pipe/html/footer.partial.tmpl
+0, -0
R pubsub/html/marketing-footer.partial.tmpl => pipe/html/marketing-footer.partial.tmpl
+0, -0
R pubsub/html/marketing.page.tmpl => pipe/html/marketing.page.tmpl
+0, -0
R pubsub/public/anim.js => pipe/public/anim.js
+0, -0
R pubsub/public/apple-touch-icon.png => pipe/public/apple-touch-icon.png
+0, -0
R pubsub/public/favicon-16x16.png => pipe/public/favicon-16x16.png
+0, -0
R pubsub/public/favicon.ico => pipe/public/favicon.ico
+0, -0
R pubsub/public/robots.txt => pipe/public/robots.txt
+0, -0
R pubsub/ssh.go => pipe/ssh.go
+6, -6
 1@@ -1,4 +1,4 @@
 2-package pubsub
 3+package pipe
 4 
 5 import (
 6 	"context"
 7@@ -19,10 +19,10 @@ import (
 8 )
 9 
10 func StartSshServer() {
11-	host := utils.GetEnv("PUBSUB_HOST", "0.0.0.0")
12-	port := utils.GetEnv("PUBSUB_SSH_PORT", "2222")
13-	portOverride := utils.GetEnv("PUBSUB_SSH_PORT_OVERRIDE", port)
14-	promPort := utils.GetEnv("PUBSUB_PROM_PORT", "9222")
15+	host := utils.GetEnv("PIPE_HOST", "0.0.0.0")
16+	port := utils.GetEnv("PIPE_SSH_PORT", "2222")
17+	portOverride := utils.GetEnv("PIPE_SSH_PORT_OVERRIDE", port)
18+	promPort := utils.GetEnv("PIPE_PROM_PORT", "9222")
19 	cfg := NewConfigSite()
20 	logger := cfg.Logger
21 	dbh := postgres.NewDB(cfg.DbURL, cfg.Logger)
22@@ -47,7 +47,7 @@ func StartSshServer() {
23 		wish.WithPublicKeyAuth(sshAuth.PubkeyAuthHandler),
24 		wish.WithMiddleware(
25 			WishMiddleware(handler),
26-			promwish.Middleware(fmt.Sprintf("%s:%s", host, promPort), "pubsub-ssh"),
27+			promwish.Middleware(fmt.Sprintf("%s:%s", host, promPort), "pipe-ssh"),
28 			wsh.LogMiddleware(logger),
29 		),
30 	)