Skip to content

Commit dbc49cb

Browse files
authored
feat(deploy): add optional Admin HTTPS (#5)
1 parent 5a59386 commit dbc49cb

25 files changed

Lines changed: 1184 additions & 420 deletions

.env.example

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
# Optional core container config overrides.
2-
# Uncomment values you want to set through environment variables.
1+
# SynapS3 container config overrides.
2+
# make docker-init adds the selected Compose files and optional Admin HTTPS
3+
# domain above this block. Keep secrets out of command-line arguments.
4+
# Set the Filecoin private key below before serving normal S3 traffic.
5+
# Other entries are optional environment overrides.
36
# Full configuration reference:
47
# https://github.com/strahe/SynapS3/blob/main/docs/en/configuration/environment.md
58

.github/workflows/docker.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,8 @@ concurrency:
2929
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
3030

3131
jobs:
32-
image_pr:
33-
name: image-pr
34-
if: github.event_name == 'pull_request'
32+
deployment:
33+
name: deployment
3534
runs-on: ${{ vars.RUNS_ON_AMD64 || vars.RUNS_ON || 'ubuntu-latest' }}
3635
timeout-minutes: 10
3736

@@ -40,6 +39,20 @@ jobs:
4039
name: Checkout
4140
uses: actions/checkout@v6
4241

42+
- name: Validate Docker deployment
43+
env:
44+
SYNAPS3_REQUIRE_DOCKER_DAEMON: '1'
45+
run: make test-docker-deployment
46+
47+
image_pr:
48+
name: image-pr
49+
if: github.event_name == 'pull_request'
50+
runs-on: ${{ vars.RUNS_ON_AMD64 || vars.RUNS_ON || 'ubuntu-latest' }}
51+
timeout-minutes: 10
52+
53+
steps:
54+
- *checkout
55+
4356
- &setup-buildx
4457
name: Set up Docker Buildx
4558
uses: docker/setup-buildx-action@v4

Makefile

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@ GOFLAGS := -trimpath
77
CGO_ENABLED := 1
88
CGO := CGO_ENABLED=$(CGO_ENABLED)
99

10+
DOCKER_DEPLOYMENT ?= sh docker/deployment.sh
11+
1012
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
1113
COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
1214
DATE := $(shell date -u '+%Y-%m-%dT%H:%M:%SZ')
1315
LDFLAGS := -X $(MODULE)/internal/buildinfo.Version=$(VERSION) \
1416
-X $(MODULE)/internal/buildinfo.Commit=$(COMMIT) \
1517
-X $(MODULE)/internal/buildinfo.Date=$(DATE)
1618

17-
.PHONY: all build build-go build-systemtest-server build-integration-server docs-build test test-fast test-race test-system test-integration test-ui-e2e test-docker-entrypoint lint fmt check verify-e2e verify-fast verify-norace verify-race clean run ui-install ui-build ui-dev ui-e2e-install
19+
.PHONY: all build build-go build-systemtest-server build-integration-server docs-build test test-fast test-race test-system test-integration test-ui-e2e test-docker-entrypoint test-docker-deployment lint fmt check verify-e2e verify-fast verify-norace verify-race clean run ui-install ui-build ui-dev ui-e2e-install
20+
.PHONY: docker-init docker-up docker-verify docker-down docker-status docker-logs docker-password
1821

1922
all: build
2023

@@ -66,6 +69,30 @@ test-ui-e2e:
6669
test-docker-entrypoint:
6770
sh docker/entrypoint.test.sh
6871

72+
test-docker-deployment:
73+
sh docker/deployment.test.sh
74+
75+
docker-init:
76+
@$(DOCKER_DEPLOYMENT) init
77+
78+
docker-up:
79+
@$(DOCKER_DEPLOYMENT) up
80+
81+
docker-verify:
82+
@$(DOCKER_DEPLOYMENT) verify
83+
84+
docker-down:
85+
@$(DOCKER_DEPLOYMENT) down
86+
87+
docker-status:
88+
@$(DOCKER_DEPLOYMENT) status
89+
90+
docker-logs:
91+
@$(DOCKER_DEPLOYMENT) logs
92+
93+
docker-password:
94+
@$(DOCKER_DEPLOYMENT) password
95+
6996
lint:
7097
@command -v golangci-lint >/dev/null 2>&1 || { echo "golangci-lint not found"; exit 1; }
7198
$(CGO) golangci-lint run

compose.admin-https.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
services:
2+
synaps3:
3+
environment:
4+
SYNAPS3_ADMIN_ADDR: 127.0.0.1:9090
5+
SYNAPS3_ADMIN_AUTH_ENABLED: "true"
6+
SYNAPS3_ADMIN_TRUSTED_PROXIES: 127.0.0.1/32
7+
8+
caddy:
9+
image: caddy:2.11.4-alpine
10+
restart: unless-stopped
11+
network_mode: host
12+
environment:
13+
ADMIN_DOMAIN: ${ADMIN_DOMAIN:?Set ADMIN_DOMAIN in .env to the public Admin hostname}
14+
depends_on:
15+
synaps3:
16+
condition: service_started
17+
configs:
18+
- source: synaps3-admin-caddyfile
19+
target: /etc/caddy/Caddyfile
20+
volumes:
21+
- caddy-data:/data
22+
- caddy-config:/config
23+
24+
configs:
25+
synaps3-admin-caddyfile:
26+
file: ./docker/Caddyfile
27+
28+
volumes:
29+
caddy-data:
30+
name: synaps3-caddy-data
31+
caddy-config:
32+
name: synaps3-caddy-config

docker/Caddyfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
admin off
3+
}
4+
5+
{$ADMIN_DOMAIN} {
6+
# Keep HSTS scoped to the Admin hostname; other subdomains may use different TLS policies.
7+
header Strict-Transport-Security "max-age=31536000"
8+
reverse_proxy 127.0.0.1:9090
9+
}

0 commit comments

Comments
 (0)