Skip to content

Commit aba6304

Browse files
authored
Merge pull request #267 from gosuda/feature/remove-ssr
Feature/remove ssr
2 parents d50e65c + 6040cbb commit aba6304

81 files changed

Lines changed: 4025 additions & 4184 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ bin/
1111
docs/
1212
*.md
1313

14+
# Local relay/tunnel state
15+
.portal-certs/
16+
*identity.json
17+
1418
# IDE
1519
.vscode/
1620
.idea/
@@ -34,5 +38,6 @@ coverage.html
3438
vendor/
3539

3640
# Frontend deps/build artifacts
41+
frontend/
3742
node_modules/
3843
**/node_modules/

.env.example

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
# Public routing, discovery, and relay identity persistence
2-
PORTAL_URL=https://localhost:4017
3-
BOOTSTRAPS=https://localhost:4017
2+
PORTAL_URL=https://localhost
43
DISCOVERY=true
54
IDENTITY_PATH=/portal-certs
65

7-
# Listener ports
8-
API_PORT=4017
9-
SNI_PORT=443
6+
# Public edge and internal listener ports.
7+
# nginx owns HTTP_PORT/HTTPS_PORT and forwards to the internal relay/frontend services.
8+
HTTP_PORT=80
9+
HTTPS_PORT=443
1010
WIREGUARD_PORT=51820
11+
# Relay API and SNI TCP ports are fixed inside the Compose network at 4017 and 443.
12+
# nginx reads these paths inside its container. Defaults map to ./.portal-certs on the host.
13+
NGINX_CERT_FILE=/etc/nginx/certs/fullchain.pem
14+
NGINX_CERT_KEY=/etc/nginx/certs/privatekey.pem
1115
# Set when enabling public UDP or raw TCP lease ports.
1216
MIN_PORT=0
1317
MAX_PORT=0
1418
UDP_ENABLED=false
1519
TCP_ENABLED=false
1620

17-
# Supported managed values: cloudflare, gcloud, hetzner, route53, vultr.
21+
# Supported managed values: cloudflare, gcloud, hetzner, njalla, route53, vultr.
1822
# Reused for ACME DNS-01, managed A records, ECH HTTPS records, and optional ENS DNS automation.
1923
ACME_DNS_PROVIDER=
2024

@@ -42,22 +46,29 @@ AWS_DNSSEC_KMS_KEY_ARN=
4246
# Vultr DNS settings (required when ACME_DNS_PROVIDER=vultr)
4347
VULTR_API_KEY=
4448

49+
# Njalla DNS settings (required when ACME_DNS_PROVIDER=njalla)
50+
NJALLA_TOKEN=
51+
4552
# ENS gasless DNS import automation. When enabled, Portal uses ACME_DNS_PROVIDER
4653
# for DNSSEC and ENS TXT automation, even when certificate files are managed manually.
4754
ENS_GASLESS_ENABLED=false
4855

49-
# Admin/auth configuration. The admin secret is generated and stored in IDENTITY_PATH/identity.json.
50-
LANDING_PAGE_ENABLED=false
56+
# Admin/auth configuration. The relay identity wallet is always allowed.
57+
ADMIN_WALLETS=
5158
# Enable when the relay is behind nginx/ingress/load balancers and should trust forwarded client IP headers.
5259
# Optionally restrict which proxy source ranges may supply those headers; leave empty for default private/loopback proxy ranges.
53-
TRUST_PROXY_HEADERS=false
60+
TRUST_PROXY_HEADERS=true
5461
TRUSTED_PROXY_CIDRS=
5562

63+
# Frontend-owned presentation state.
64+
# Bundled Compose stores the saved override under ./.portal-certs/frontend-state/state.json.
65+
LANDING_PAGE_ENABLED=false
66+
5667
# Optional: auto-generated thumbnail screenshots for tunnel apps without a thumbnail.
57-
# Requires the headless-shell sidecar (chromedp/headless-shell) in docker-compose.
58-
# Leave empty or remove to disable. See docs/src/routes/deployment/+page.md.
68+
# Used by the portal-api service. Requires the headless-shell sidecar.
69+
# Leave empty to keep generated screenshots disabled. See docs/src/routes/deployment/+page.md.
5970
# HEADLESS_SHELL_URL=ws://headless-shell:9222
6071

6172
X402_FACILITATOR_ENABLED=false
6273
X402_NETWORK=eip155:84532
63-
X402_RPC_URL=https://base-sepolia-rpc.publicnode.com
74+
X402_RPC_URL=https://base-sepolia-rpc.publicnode.com

.github/workflows/branch-artifacts.yml

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ on:
1414
env:
1515
BUILD_REF: ${{ inputs.ref || github.ref_name }}
1616
REGISTRY: ghcr.io
17-
IMAGE_NAME: gosuda/portal
1817
PLATFORMS: linux/amd64,linux/arm64
1918

2019
concurrency:
@@ -23,7 +22,7 @@ concurrency:
2322

2423
jobs:
2524
build:
26-
name: Build Binaries
25+
name: Build Artifacts
2726
runs-on: ubuntu-latest
2827

2928
steps:
@@ -52,9 +51,17 @@ jobs:
5251
echo "short_sha=$short_sha" >> "$GITHUB_OUTPUT"
5352
echo "commit_sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
5453
{
55-
echo "image_tags<<EOF"
56-
echo "${REGISTRY}/${IMAGE_NAME}:branch-${safe_ref}"
57-
echo "${REGISTRY}/${IMAGE_NAME}:branch-${safe_ref}-${short_sha}"
54+
echo "portal_image_tags<<EOF"
55+
echo "${REGISTRY}/gosuda/portal:branch-${safe_ref}"
56+
echo "${REGISTRY}/gosuda/portal:branch-${safe_ref}-${short_sha}"
57+
echo "EOF"
58+
echo "frontend_image_tags<<EOF"
59+
echo "${REGISTRY}/gosuda/portal-frontend:branch-${safe_ref}"
60+
echo "${REGISTRY}/gosuda/portal-frontend:branch-${safe_ref}-${short_sha}"
61+
echo "EOF"
62+
echo "portal_api_image_tags<<EOF"
63+
echo "${REGISTRY}/gosuda/portal-api:branch-${safe_ref}"
64+
echo "${REGISTRY}/gosuda/portal-api:branch-${safe_ref}-${short_sha}"
5865
echo "EOF"
5966
} >> "$GITHUB_OUTPUT"
6067
@@ -71,18 +78,51 @@ jobs:
7178
- name: Set up Docker Buildx
7279
uses: docker/setup-buildx-action@v3
7380

74-
- name: Build and push Docker image
81+
- name: Build and push portal Docker image
82+
uses: docker/build-push-action@v6
83+
with:
84+
context: .
85+
file: Dockerfile
86+
platforms: ${{ env.PLATFORMS }}
87+
push: true
88+
tags: ${{ steps.meta.outputs.portal_image_tags }}
89+
labels: |
90+
org.opencontainers.image.source=https://github.com/${{ github.repository }}
91+
org.opencontainers.image.revision=${{ steps.meta.outputs.commit_sha }}
92+
org.opencontainers.image.ref.name=${{ env.BUILD_REF }}
93+
cache-from: type=gha,scope=portal
94+
cache-to: type=gha,mode=max,scope=portal
95+
96+
- name: Build and push frontend Docker image
97+
uses: docker/build-push-action@v6
98+
with:
99+
context: ./frontend
100+
file: ./frontend/Dockerfile
101+
platforms: ${{ env.PLATFORMS }}
102+
push: true
103+
tags: ${{ steps.meta.outputs.frontend_image_tags }}
104+
labels: |
105+
org.opencontainers.image.source=https://github.com/${{ github.repository }}
106+
org.opencontainers.image.revision=${{ steps.meta.outputs.commit_sha }}
107+
org.opencontainers.image.ref.name=${{ env.BUILD_REF }}
108+
cache-from: type=gha,scope=frontend
109+
cache-to: type=gha,mode=max,scope=frontend
110+
111+
- name: Build and push portal API Docker image
75112
uses: docker/build-push-action@v6
76113
with:
114+
context: ./frontend
115+
file: ./frontend/Dockerfile
116+
target: api
77117
platforms: ${{ env.PLATFORMS }}
78118
push: true
79-
tags: ${{ steps.meta.outputs.image_tags }}
119+
tags: ${{ steps.meta.outputs.portal_api_image_tags }}
80120
labels: |
81121
org.opencontainers.image.source=https://github.com/${{ github.repository }}
82122
org.opencontainers.image.revision=${{ steps.meta.outputs.commit_sha }}
83123
org.opencontainers.image.ref.name=${{ env.BUILD_REF }}
84-
cache-from: type=gha,mode=max
85-
cache-to: type=gha,mode=max
124+
cache-from: type=gha,scope=portal-api
125+
cache-to: type=gha,mode=max,scope=portal-api
86126

87127
- name: Build binaries
88128
shell: bash

.github/workflows/cd.yml

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ on:
77

88
env:
99
REGISTRY: ghcr.io
10-
IMAGE_NAME: gosuda/portal
1110
PLATFORMS: linux/amd64,linux/arm64
1211

1312
concurrency:
@@ -16,11 +15,28 @@ concurrency:
1615

1716
jobs:
1817
build-and-push:
19-
name: Build and Push Docker Image
18+
name: Build and Push Docker Images
2019
runs-on: ubuntu-latest
2120
permissions:
2221
contents: read
2322
packages: write
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
include:
27+
- image: gosuda/portal
28+
context: .
29+
file: Dockerfile
30+
cache_scope: portal
31+
- image: gosuda/portal-frontend
32+
context: ./frontend
33+
file: ./frontend/Dockerfile
34+
cache_scope: frontend
35+
- image: gosuda/portal-api
36+
context: ./frontend
37+
file: ./frontend/Dockerfile
38+
target: api
39+
cache_scope: portal-api
2440

2541
steps:
2642
- name: Checkout code
@@ -43,7 +59,7 @@ jobs:
4359
id: meta
4460
uses: docker/metadata-action@v5
4561
with:
46-
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
62+
images: ${{ env.REGISTRY }}/${{ matrix.image }}
4763
tags: |
4864
type=raw,value=latest,enable={{is_default_branch}}
4965
type=semver,pattern={{version}}
@@ -54,12 +70,15 @@ jobs:
5470
- name: Build and push Docker image
5571
uses: docker/build-push-action@v6
5672
with:
73+
context: ${{ matrix.context }}
74+
file: ${{ matrix.file }}
75+
target: ${{ matrix.target }}
5776
platforms: ${{ env.PLATFORMS }}
5877
push: true
5978
tags: ${{ steps.meta.outputs.tags }}
6079
labels: ${{ steps.meta.outputs.labels }}
61-
cache-from: type=gha,mode=max
62-
cache-to: type=gha,mode=max
80+
cache-from: type=gha,scope=${{ matrix.cache_scope }}
81+
cache-to: type=gha,mode=max,scope=${{ matrix.cache_scope }}
6382

6483
release-binaries:
6584
name: Build and Release Tunnel Binaries

.gitignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
bin/
1212
chat
1313

14-
cmd/relay-server/dist/app
1514
data/
16-
.portal-certs
1715

1816
# Test binary, built with `go test -c`
1917
*.test
@@ -146,3 +144,7 @@ fabric.properties
146144

147145
# Nested workspace (separate keyless_tls project; not part of the portal module)
148146
keyless_tls/
147+
148+
# Local relay/tunnel state
149+
.portal-certs/
150+
*identity.json

Dockerfile

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,5 @@
11
# syntax=docker/dockerfile:1
22

3-
# Stage 1: Build frontend (Node.js)
4-
FROM --platform=$BUILDPLATFORM node:22-slim AS frontend-builder
5-
WORKDIR /src
6-
7-
RUN apt-get update && apt-get install -y --no-install-recommends \
8-
make && rm -rf /var/lib/apt/lists/*
9-
10-
COPY frontend ./frontend
11-
COPY utils ./utils
12-
COPY Makefile ./
13-
14-
RUN --mount=type=cache,target=/root/.npm \
15-
make build-frontend
16-
17-
# Stage 2: Build Go artifacts
183
FROM --platform=$BUILDPLATFORM golang:1 AS go-builder
194
WORKDIR /src
205

@@ -25,8 +10,7 @@ COPY go.mod go.sum ./
2510
RUN --mount=type=cache,target=/go/pkg/mod go mod download
2611

2712
COPY . .
28-
RUN rm -rf bin/
29-
COPY --from=frontend-builder /src/cmd/relay-server/dist/app ./cmd/relay-server/dist/app
13+
RUN rm -rf bin/ cmd/relay-server/dist && mkdir -p cmd/relay-server/dist && touch cmd/relay-server/dist/.gitkeep
3014

3115
ARG TARGETOS
3216
ARG TARGETARCH
@@ -35,7 +19,7 @@ RUN --mount=type=cache,target=/go/pkg/mod \
3519
make build-tunnel && \
3620
GOOS=${TARGETOS} GOARCH=${TARGETARCH} make build-server
3721

38-
FROM gcr.io/distroless/static-debian12:nonroot
22+
FROM gcr.io/distroless/static-debian12:nonroot AS runtime
3923

4024
COPY --from=go-builder /src/bin/relay-server /usr/bin/relay-server
4125

Makefile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ help:
1616
@echo " make fmt - Apply gofmt/goimports"
1717
@echo " make lint-auto - Run autofix lint/format pipeline"
1818
@echo " make test - Run Go tests"
19-
@echo " make build - Build everything (frontend, tunnel, server)"
19+
@echo " make build - Build Go tunnel and relay server artifacts"
2020
@echo " make build-frontend - Build React frontend (Tailwind CSS 4)"
2121
@echo " make build-docs - Build documentation site (SvelteKit)"
2222
@echo " make build-tunnel - Build portal-tunnel binaries"
23-
@echo " make build-server - Build Go relay server (frontend built separately)"
23+
@echo " make build-server - Build Go relay server"
2424
@echo " make run - Run relay server"
2525
@echo " make clean - Remove build artifacts"
2626

@@ -61,12 +61,11 @@ run:
6161
./bin/relay-server
6262

6363
# Convenience target
64-
build: build-frontend build-tunnel build-server
64+
build: build-tunnel build-server
6565

6666
# Build React frontend with Tailwind CSS 4
6767
build-frontend:
6868
@echo "[frontend] building React frontend..."
69-
@mkdir -p cmd/relay-server/dist/app
7069
@cd frontend && npm i && npm run build
7170
@echo "[frontend] build complete"
7271

@@ -97,8 +96,8 @@ build-server:
9796

9897
clean:
9998
rm -rf bin
100-
rm -rf cmd/relay-server/dist/app
10199
rm -rf cmd/relay-server/dist/tunnel
100+
rm -rf frontend/dist
102101

103102
# Run the uniformity probe. Extra flags are passed through after the target name:
104103
# make load-test -- -clients 1000 -relays 5

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ cd portal-tunnel && cp .env.example .env
109109
docker compose up
110110
```
111111

112-
For public deployment with DNS automation (ACME), TCP/UDP port ranges, and admin settings, see [Deployment](docs/src/routes/deployment/+page.md).
112+
For public deployment with DNS automation (ACME), TCP/UDP port ranges, and relay policy, see [Deployment](docs/src/routes/deployment/+page.md).
113113

114114
## How End-to-End Encryption Works
115115

0 commit comments

Comments
 (0)