Skip to content

Commit

Permalink
Refactor pubsub->pipe
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniomika committed Oct 11, 2024
1 parent 88726f8 commit 8dfc7cc
Show file tree
Hide file tree
Showing 23 changed files with 80 additions and 80 deletions.
32 changes: 16 additions & 16 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -146,19 +146,19 @@ AUTH_DOMAIN=http://auth.dev.pico.sh:3006
AUTH_ISSUER=pico.sh
AUTH_WEB_PORT=3000

PUBSUB_CADDYFILE=./caddy/Caddyfile
PUBSUB_V4=
PUBSUB_V6=
PUBSUB_HTTP_V4=$PUBSUB_V4:80
PUBSUB_HTTP_V6=[$PUBSUB_V6]:80
PUBSUB_HTTPS_V4=$PUBSUB_V4:443
PUBSUB_HTTPS_V6=[$PUBSUB_V6]:443
PUBSUB_SSH_V4=$PUBSUB_V4:22
PUBSUB_SSH_V6=[$PUBSUB_V6]:22
PUBSUB_HOST=
PUBSUB_SSH_PORT=2222
PUBSUB_WEB_PORT=3000
PUBSUB_PROM_PORT=9222
PUBSUB_DOMAIN=pubsub.dev.pico.sh:3001
PUBSUB_PROTOCOL=http
PUBSUB_DEBUG=1
PIPE_CADDYFILE=./caddy/Caddyfile
PIPE_V4=
PIPE_V6=
PIPE_HTTP_V4=$PIPE_V4:80
PIPE_HTTP_V6=[$PIPE_V6]:80
PIPE_HTTPS_V4=$PIPE_V4:443
PIPE_HTTPS_V6=[$PIPE_V6]:443
PIPE_SSH_V4=$PIPE_V4:22
PIPE_SSH_V6=[$PIPE_V6]:22
PIPE_HOST=
PIPE_SSH_PORT=2222
PIPE_WEB_PORT=3000
PIPE_PROM_PORT=9222
PIPE_DOMAIN=pipe.dev.pico.sh:3001
PIPE_PROTOCOL=http
PIPE_DEBUG=1
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
needs: test
strategy:
matrix:
APP: [prose, pastes, imgs, pgs, feeds, pubsub]
APP: [prose, pastes, imgs, pgs, feeds, pipe]
steps:
- name: Checkout repo
uses: actions/checkout@v3
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ bp-%: bp-setup
$(DOCKER_BUILDX_BUILD) --build-arg "APP=$*" -t "ghcr.io/picosh/pico/$*-web:$(DOCKER_TAG)" --target release-web .
.PHONY: bp-%

bp-all: bp-prose bp-pastes bp-imgs bp-feeds bp-pgs bp-auth bp-bouncer bp-pubsub
bp-all: bp-prose bp-pastes bp-imgs bp-feeds bp-pgs bp-auth bp-bouncer bp-pipe
.PHONY: bp-all

build-auth:
Expand All @@ -74,7 +74,7 @@ build-%:
go build -o "build/$*-ssh" "./cmd/$*/ssh"
.PHONY: build-%

build: build-prose build-pastes build-imgs build-feeds build-pgs build-auth build-pico build-pubsub
build: build-prose build-pastes build-imgs build-feeds build-pgs build-auth build-pico build-pipe
.PHONY: build

store-clean:
Expand Down
7 changes: 7 additions & 0 deletions cmd/pipe/ssh/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

import "github.com/picosh/pico/pipe"

func main() {
pipe.StartSshServer()
}
7 changes: 7 additions & 0 deletions cmd/pipe/web/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

import "github.com/picosh/pico/pipe"

func main() {
pipe.StartApiServer()
}
7 changes: 0 additions & 7 deletions cmd/pubsub/ssh/main.go

This file was deleted.

7 changes: 0 additions & 7 deletions cmd/pubsub/web/main.go

This file was deleted.

10 changes: 5 additions & 5 deletions docker-compose.override.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,24 @@ services:
- ./data/pastes-ssh/data:/app/ssh_data
ports:
- "2221:2222"
pubsub-web:
pipe-web:
build:
args:
APP: pubsub
APP: pipe
target: release-web
env_file:
- .env.example
ports:
- "3001:3000"
pubsub-ssh:
pipe-ssh:
build:
args:
APP: pubsub
APP: pipe
target: release-ssh
env_file:
- .env.example
volumes:
- ./data/pubsub-ssh/data:/app/ssh_data
- ./data/pipe-ssh/data:/app/ssh_data
ports:
- "2221:2222"
prose-web:
Expand Down
44 changes: 22 additions & 22 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,50 +88,50 @@ services:
ports:
- "${PASTES_SSH_V4:-22}:2222"
- "${PASTES_SSH_V6:-[::1]:22}:2222"
pubsub-caddy:
pipe-caddy:
image: ghcr.io/picosh/pico/caddy:latest
restart: always
networks:
- pubsub
- pipe
env_file:
- .env.prod
environment:
APP_DOMAIN: ${PUBSUB_DOMAIN:-pipe.pico.sh}
APP_EMAIL: ${PUBSUB_EMAIL:[email protected]}
APP_DOMAIN: ${PIPE_DOMAIN:-pipe.pico.sh}
APP_EMAIL: ${PIPE_EMAIL:[email protected]}
volumes:
- ${PUBSUB_CADDYFILE}:/etc/caddy/Caddyfile
- ./data/pubsub-caddy/data:/data
- ./data/pubsub-caddy/config:/config
- ${PIPE_CADDYFILE}:/etc/caddy/Caddyfile
- ./data/pipe-caddy/data:/data
- ./data/pipe-caddy/config:/config
ports:
- "${PUBSUB_HTTPS_V4:-443}:443"
- "${PUBSUB_HTTP_V4:-80}:80"
- "${PUBSUB_HTTPS_V6:-[::1]:443}:443"
- "${PUBSUB_HTTP_V6:-[::1]:80}:80"
- "${PIPE_HTTPS_V4:-443}:443"
- "${PIPE_HTTP_V4:-80}:80"
- "${PIPE_HTTPS_V6:-[::1]:443}:443"
- "${PIPE_HTTP_V6:-[::1]:80}:80"
profiles:
- pubsub
- pipe
- caddy
- all
pubsub-web:
pipe-web:
networks:
pubsub:
pipe:
aliases:
- web
env_file:
- .env.prod
volumes:
- ./data/pubsub-ssh/data:/app/ssh_data
pubsub-ssh:
- ./data/pipe-ssh/data:/app/ssh_data
pipe-ssh:
networks:
pubsub:
pipe:
aliases:
- ssh
env_file:
- .env.prod
volumes:
- ./data/pubsub-ssh/data:/app/ssh_data
- ./data/pipe-ssh/data:/app/ssh_data
ports:
- "${PUBSUB_SSH_V4:-22}:2222"
- "${PUBSUB_SSH_V6:-[::1]:22}:2222"
- "${PIPE_SSH_V4:-22}:2222"
- "${PIPE_SSH_V6:-[::1]:22}:2222"
prose-caddy:
image: ghcr.io/picosh/pico/caddy:latest
restart: always
Expand Down Expand Up @@ -396,9 +396,9 @@ networks:
ipam:
config:
- subnet: 172.25.0.0/16
pubsub:
pipe:
driver_opts:
com.docker.network.bridge.name: pubsub
com.docker.network.bridge.name: pipe
ipam:
config:
- subnet: 172.27.0.0/16
12 changes: 6 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,18 @@ services:
- pastes
- services
- all
pubsub-web:
image: ghcr.io/picosh/pico/pubsub-web:latest
pipe-web:
image: ghcr.io/picosh/pico/pipe-web:latest
restart: always
profiles:
- pubsub
- pipe
- services
- all
pubsub-ssh:
image: ghcr.io/picosh/pico/pubsub-ssh:latest
pipe-ssh:
image: ghcr.io/picosh/pico/pipe-ssh:latest
restart: always
profiles:
- pubsub
- pipe
- services
- all
prose-web:
Expand Down
2 changes: 1 addition & 1 deletion pubsub/api.go → pipe/api.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package pubsub
package pipe

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion pubsub/cli.go → pipe/cli.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package pubsub
package pipe

import (
"bytes"
Expand Down
12 changes: 6 additions & 6 deletions pubsub/config.go → pipe/config.go
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
package pubsub
package pipe

import (
"github.com/picosh/pico/shared"
"github.com/picosh/utils"
)

func NewConfigSite() *shared.ConfigSite {
domain := utils.GetEnv("PUBSUB_DOMAIN", "pipe.pico.sh")
port := utils.GetEnv("PUBSUB_WEB_PORT", "3000")
domain := utils.GetEnv("PIPE_DOMAIN", "pipe.pico.sh")
port := utils.GetEnv("PIPE_WEB_PORT", "3000")
dbURL := utils.GetEnv("DATABASE_URL", "")
protocol := utils.GetEnv("PUBSUB_PROTOCOL", "https")
protocol := utils.GetEnv("PIPE_PROTOCOL", "https")

return &shared.ConfigSite{
Domain: domain,
Port: port,
Protocol: protocol,
DbURL: dbURL,
Logger: shared.CreateLogger("pubsub"),
Space: "pubsub",
Logger: shared.CreateLogger("pipe"),
Space: "pipe",
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
12 changes: 6 additions & 6 deletions pubsub/ssh.go → pipe/ssh.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package pubsub
package pipe

import (
"context"
Expand All @@ -19,10 +19,10 @@ import (
)

func StartSshServer() {
host := utils.GetEnv("PUBSUB_HOST", "0.0.0.0")
port := utils.GetEnv("PUBSUB_SSH_PORT", "2222")
portOverride := utils.GetEnv("PUBSUB_SSH_PORT_OVERRIDE", port)
promPort := utils.GetEnv("PUBSUB_PROM_PORT", "9222")
host := utils.GetEnv("PIPE_HOST", "0.0.0.0")
port := utils.GetEnv("PIPE_SSH_PORT", "2222")
portOverride := utils.GetEnv("PIPE_SSH_PORT_OVERRIDE", port)
promPort := utils.GetEnv("PIPE_PROM_PORT", "9222")
cfg := NewConfigSite()
logger := cfg.Logger
dbh := postgres.NewDB(cfg.DbURL, cfg.Logger)
Expand All @@ -47,7 +47,7 @@ func StartSshServer() {
wish.WithPublicKeyAuth(sshAuth.PubkeyAuthHandler),
wish.WithMiddleware(
WishMiddleware(handler),
promwish.Middleware(fmt.Sprintf("%s:%s", host, promPort), "pubsub-ssh"),
promwish.Middleware(fmt.Sprintf("%s:%s", host, promPort), "pipe-ssh"),
wsh.LogMiddleware(logger),
),
)
Expand Down

0 comments on commit 8dfc7cc

Please sign in to comment.