repos / pico

pico services mono repo
git clone https://github.com/picosh/pico.git

commit
e686672
parent
8c838e2
author
Eric Bower
date
2025-07-13 17:02:00 -0400 EDT
docs(pgs): selfhost copy
5 files changed,  +13, -10
M SELFHOST.md
+4, -4
 1@@ -1,15 +1,15 @@
 2 # self-host guide
 3 
 4 `pico` as a platform is not designed to be self-hosted, even though all the code
 5-is open and lives inside this repo. We has no issues with self-hosting this
 6-platform in its entirety but it is simply not a design goal or focus for us.
 7+is open and lives inside this repo. We have no issues with people self-hosting this
 8+platform in its entirety but it's not a design goal or focus for us.
 9 
10 Having said that, we do have components of this platform that we do officially
11 support for self-hosting.
12 
13 # tuns.sh
14 
15-Our tunneling service is simply a managed `sish` service that has some features
16+Our tunneling service is a managed `sish` service that has some optional features
17 related to pico authentication and authorization.
18 
19 `sish` is a stateless go binary that can be completely configured from a single
20@@ -23,4 +23,4 @@ Our static site hosting service has a dedicated docs repo that contains all the
21 information you need to self-host pgs here: https://github.com/picosh/pgs/
22 
23 `pgs` requires extra dependencies primarily for generating TLS certificates
24-on-the-fly.
25+on-the-fly and image manipulation APIs.
M cmd/pgs/standalone/main.go
+2, -2
 1@@ -41,7 +41,7 @@ func main() {
 2 
 3 			userName := args[2]
 4 			pubkeyRaw := strings.Join(args[3:], " ")
 5-			key, _, _, _, err := ssh.ParseAuthorizedKey([]byte(pubkeyRaw))
 6+			key, comment, _, _, err := ssh.ParseAuthorizedKey([]byte(pubkeyRaw))
 7 			if err != nil {
 8 				logger.Error("parse pubkey", "err", err)
 9 				return
10@@ -49,7 +49,7 @@ func main() {
11 			pubkey := utils.KeyForKeyText(key)
12 			logger.Info("init cli", "userName", userName, "pubkey", pubkey)
13 
14-			err = dbpool.RegisterAdmin(userName, pubkey)
15+			err = dbpool.RegisterAdmin(userName, pubkey, comment)
16 			if err != nil {
17 				panic(err)
18 			}
M pkg/apps/pgs/db/db.go
+1, -1
1@@ -22,7 +22,7 @@ type PgsDB interface {
2 	FindProjectsByPrefix(userID, name string) ([]*db.Project, error)
3 	FindProjects(by string) ([]*db.Project, error)
4 
5-	RegisterAdmin(username string, pubkey string) error
6+	RegisterAdmin(username, pubkey, pubkeyName string) error
7 
8 	Close() error
9 }
M pkg/apps/pgs/db/memory.go
+1, -1
1@@ -188,6 +188,6 @@ func (me *MemoryDB) UpdateProjectAcl(userID, name string, acl db.ProjectAcl) err
2 	return errNotImpl
3 }
4 
5-func (me *MemoryDB) RegisterAdmin(username, pubkey string) error {
6+func (me *MemoryDB) RegisterAdmin(username, pubkey, pubkeyName string) error {
7 	return errNotImpl
8 }
M pkg/apps/pgs/db/postgres.go
+5, -2
 1@@ -241,7 +241,10 @@ func (me *PgsPsqlDB) UpdateProjectAcl(userID, name string, acl db.ProjectAcl) er
 2 	return err
 3 }
 4 
 5-func (me *PgsPsqlDB) RegisterAdmin(username, pubkey string) error {
 6+func (me *PgsPsqlDB) RegisterAdmin(username, pubkey, pubkeyName string) error {
 7+	if pubkeyName == "" {
 8+		pubkeyName = "main"
 9+	}
10 	var userID string
11 	row := me.Db.QueryRow("INSERT INTO app_users (name) VALUES ($1) RETURNING id", username)
12 	err := row.Scan(&userID)
13@@ -249,7 +252,7 @@ func (me *PgsPsqlDB) RegisterAdmin(username, pubkey string) error {
14 		return err
15 	}
16 
17-	_, err = me.Db.Exec("INSERT INTO public_keys (user_id, name, public_key) VALUES ($1, 'main', $2)", userID, pubkey)
18+	_, err = me.Db.Exec("INSERT INTO public_keys (user_id, name, public_key) VALUES ($1, $2, $3)", userID, pubkeyName, pubkey)
19 	if err != nil {
20 		return err
21 	}