mirror of
https://github.com/OutlineFoundation/outline-server.git
synced 2026-10-21 20:10:58 +00:00
Refactor outline-caddy build to use go tool xcaddy and rename CaddyWebServerConfig to WebServerConfig
This commit is contained in:
parent
efc0886eb8
commit
739d2ec436
6 changed files with 24 additions and 39 deletions
4
go.mod
4
go.mod
|
|
@ -10,6 +10,10 @@ require (
|
|||
github.com/google/addlicense v1.1.1
|
||||
)
|
||||
|
||||
tool (
|
||||
github.com/caddyserver/xcaddy/cmd/xcaddy
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/Jigsaw-Code/outline-sdk v0.0.18-0.20241106233708-faffebb12629 // indirect
|
||||
github.com/Jigsaw-Code/outline-sdk/x v0.0.2-0.20250304133713-52f1a365e5ed // indirect
|
||||
|
|
|
|||
|
|
@ -18,31 +18,17 @@ requires:
|
|||
vars: [OUTPUT_BASE]
|
||||
|
||||
tasks:
|
||||
download_xcaddy:
|
||||
desc: Download xcaddy
|
||||
requires: {vars: [TARGET_DIR, XCADDY_OS, XCADDY_ARCH]}
|
||||
vars:
|
||||
XCADDY_VERSION: v0.4.5
|
||||
XCADDY_VERSION_NUMBER: '{{trimPrefix "v" .XCADDY_VERSION}}'
|
||||
XCADDY_ARCH_LABEL: '{{if eq .XCADDY_ARCH "x86_64"}}amd64{{else if eq .XCADDY_ARCH "arm64"}}arm64{{else if eq .XCADDY_ARCH "armv6"}}armv6{{else if eq .XCADDY_ARCH "armv7"}}armv7{{else}}{{.XCADDY_ARCH}}{{end}}'
|
||||
XCADDY_OS_LABEL: '{{if eq .XCADDY_OS "darwin"}}mac{{else}}{{.XCADDY_OS}}{{end}}'
|
||||
XCADDY_FILE: 'xcaddy_{{.XCADDY_VERSION_NUMBER}}_{{.XCADDY_OS_LABEL}}_{{.XCADDY_ARCH_LABEL}}{{if eq .XCADDY_OS_LABEL "windows"}}.zip{{else}}.tar.gz{{end}}'
|
||||
XCADDY_URL: 'https://github.com/caddyserver/xcaddy/releases/download/{{.XCADDY_VERSION}}/{{.XCADDY_FILE}}'
|
||||
build_outline_caddy:
|
||||
desc: Build the OutlineCaddy binary using xcaddy
|
||||
requires: {vars: [TARGET_DIR, TARGET_OS, GOARCH]}
|
||||
cmds:
|
||||
- mkdir -p '{{.TARGET_DIR}}'
|
||||
- |
|
||||
tmpdir=$(mktemp -d)
|
||||
curl -fsSL '{{.XCADDY_URL}}' -o "$tmpdir/xcaddy.pkg"
|
||||
{{- if eq .XCADDY_OS "windows" }}
|
||||
unzip -oq "$tmpdir/xcaddy.pkg" -d '{{.TARGET_DIR}}'
|
||||
{{- else }}
|
||||
tar -xzf "$tmpdir/xcaddy.pkg" -C '{{.TARGET_DIR}}' xcaddy
|
||||
{{- end }}
|
||||
rm -rf "$tmpdir"
|
||||
- |
|
||||
{{- if ne .XCADDY_OS_LABEL "windows" -}}
|
||||
chmod +x '{{joinPath .TARGET_DIR "xcaddy"}}'
|
||||
{{- end -}}
|
||||
XCADDY_GOOS={{.TARGET_OS}} XCADDY_GOARCH={{.GOARCH}} go tool xcaddy build \
|
||||
--output '{{joinPath .TARGET_DIR "outline-caddy"}}' \
|
||||
--with github.com/Jigsaw-Code/outline-ss-server/outlinecaddy@v0.0.1 \
|
||||
--with github.com/iamd3vil/caddy_yaml_adapter \
|
||||
--with github.com/mholt/caddy-l4
|
||||
|
||||
build:
|
||||
desc: Build the Outline Server Node.js app
|
||||
|
|
@ -66,16 +52,11 @@ tasks:
|
|||
vars: {TARGET_DIR: '{{.BIN_DIR}}'}
|
||||
# Set CGO_ENABLED=0 to force static linkage. See https://mt165.co.uk/blog/static-link-go/.
|
||||
- GOOS={{.TARGET_OS}} GOARCH={{.GOARCH}} CGO_ENABLED=0 go build -ldflags='-s -w -X main.version=embedded' -o '{{.BIN_DIR}}/' github.com/Jigsaw-Code/outline-ss-server/cmd/outline-ss-server
|
||||
- task: download_xcaddy
|
||||
- task: build_outline_caddy
|
||||
vars:
|
||||
TARGET_DIR: '{{.BIN_DIR}}'
|
||||
XCADDY_OS: '{{.TARGET_OS}}'
|
||||
XCADDY_ARCH: '{{.GOARCH}}'
|
||||
- |
|
||||
'{{joinPath .BIN_DIR "xcaddy"}}' build --output '{{joinPath .BIN_DIR "outline-caddy"}}' \
|
||||
--with github.com/Jigsaw-Code/outline-ss-server/outlinecaddy@v0.0.1 \
|
||||
--with github.com/iamd3vil/caddy_yaml_adapter@v0.0.0-20200503183711-d479c29b475a \
|
||||
--with github.com/mholt/caddy-l4@v0.0.0-20251201210923-0c96591f5650
|
||||
TARGET_OS: '{{.TARGET_OS}}'
|
||||
GOARCH: '{{.GOARCH}}'
|
||||
|
||||
start:
|
||||
desc: Run the Outline server locally
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ paths:
|
|||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/CaddyWebServerConfig"
|
||||
$ref: "#/components/schemas/WebServerConfig"
|
||||
examples:
|
||||
'Enable with auto HTTPS':
|
||||
value: '{"enabled": true, "autoHttps": true, "email": "admin@example.com", "domain": "example.com"}'
|
||||
|
|
@ -730,7 +730,7 @@ components:
|
|||
$ref: "#/components/schemas/ListenerConfig"
|
||||
description: WebSocket packet (UDP) listener configuration
|
||||
|
||||
CaddyWebServerConfig:
|
||||
WebServerConfig:
|
||||
properties:
|
||||
enabled:
|
||||
type: boolean
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import * as errors from '../model/errors';
|
|||
import * as version from './version';
|
||||
|
||||
import {ManagerMetrics} from './manager_metrics';
|
||||
import {ServerConfigJson, ListenersForNewAccessKeys, CaddyWebServerConfig} from './server_config';
|
||||
import {ServerConfigJson, ListenersForNewAccessKeys, WebServerConfig} from './server_config';
|
||||
import {SharedMetricsPublisher} from './shared_metrics';
|
||||
import {ShadowsocksServer} from '../model/shadowsocks_server';
|
||||
import type {OutlineCaddyController} from './outline_caddy_server';
|
||||
|
|
@ -851,7 +851,7 @@ export class ShadowsocksManagerService {
|
|||
try {
|
||||
logging.debug(`configureCaddyWebServer request ${JSON.stringify(req.params)}`);
|
||||
|
||||
const config = req.params as unknown as CaddyWebServerConfig;
|
||||
const config = req.params as unknown as WebServerConfig;
|
||||
if (!config || typeof config !== 'object') {
|
||||
return next(
|
||||
new restifyErrors.InvalidArgumentError({statusCode: 400}, 'Invalid Caddy configuration')
|
||||
|
|
@ -892,7 +892,7 @@ export class ShadowsocksManagerService {
|
|||
// Store Caddy configuration
|
||||
const configData = this.serverConfig.data();
|
||||
if (configData) {
|
||||
const caddyConfig: CaddyWebServerConfig = {
|
||||
const caddyConfig: WebServerConfig = {
|
||||
enabled: config.enabled ?? false,
|
||||
autoHttps: config.autoHttps ?? false,
|
||||
email: config.email,
|
||||
|
|
|
|||
|
|
@ -21,12 +21,12 @@ import * as yaml from 'js-yaml';
|
|||
import * as file from '../infrastructure/file';
|
||||
import * as logging from '../infrastructure/logging';
|
||||
import {AccessKey, ListenerType} from '../model/access_key';
|
||||
import {CaddyWebServerConfig, ListenerConfig, ListenersForNewAccessKeys} from './server_config';
|
||||
import {WebServerConfig, ListenerConfig, ListenersForNewAccessKeys} from './server_config';
|
||||
|
||||
export interface OutlineCaddyConfigPayload {
|
||||
accessKeys: AccessKey[];
|
||||
listeners?: ListenersForNewAccessKeys;
|
||||
caddyConfig?: CaddyWebServerConfig;
|
||||
caddyConfig?: WebServerConfig;
|
||||
hostname?: string;
|
||||
apiPort?: number; // Internal API port for reverse proxy
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ export interface ListenersForNewAccessKeys {
|
|||
}
|
||||
|
||||
// Caddy web server configuration
|
||||
export interface CaddyWebServerConfig {
|
||||
export interface WebServerConfig {
|
||||
enabled?: boolean;
|
||||
autoHttps?: boolean;
|
||||
email?: string; // For ACME
|
||||
|
|
@ -56,7 +56,7 @@ export interface ServerConfigJson {
|
|||
// Listeners configuration for new access keys (supersedes portForNewAccessKeys)
|
||||
listenersForNewAccessKeys?: ListenersForNewAccessKeys;
|
||||
// Caddy web server configuration for automatic HTTPS
|
||||
caddyWebServer?: CaddyWebServerConfig;
|
||||
caddyWebServer?: WebServerConfig;
|
||||
// Which staged rollouts we should force enabled or disabled.
|
||||
rollouts?: RolloutConfigJson[];
|
||||
// We don't serialize the shadowbox version, this is obtained dynamically from node.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue