Blockers fixed: - Docker: create /app/data with tbin ownership, use named volume in docker-compose (was: bind mount broke non-root user, MkdirAll failed on startup) - Remove /metrics from main HTTP mux (was: exposed publicly even when --metrics-addr empty) - Implement per-IP rate limiting with ipLimiter (map + cleanup goroutine) (was: single global limiter, docs said per-IP but wasn't) - Fix Prometheus label cardinality: use fixed endpoint labels instead of r.URL.Path (was: unbounded memory growth from unique paths as labels) Non-blocking fixes: - Remove redundant purgeRunning atomic.Bool (keep only purgeMu.TryLock) - Remove dead code: getClientIP (replaced by getRemoteIP), unreachable health case in handleHTTP, _ = host in TCP limiter - Fix MaxBytesReader/413: use r.ParseForm() to detect body-too-large errors properly - Track TCP handlers and async operations with sync.WaitGroup for graceful shutdown - CI: add test job with go build, vet, gofmt check, go test before Docker build - CI: bump actions/checkout to v4, add PR trigger - docker-compose: use named volume tbin-data instead of bind mount - Dockerfile: pin tbin user to UID 1000, add VOLUME /app/data - README: document non-root user, named volume, per-IP rate limiting All checks pass: go build, go vet, gofmt -l
71 lines
1.6 KiB
YAML
71 lines
1.6 KiB
YAML
name: build
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- "main"
|
|
- "security-performance-improvements"
|
|
pull_request:
|
|
branches:
|
|
- "main"
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: golang:1.27-alpine
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: go mod download
|
|
run: go mod download
|
|
|
|
- name: go build
|
|
run: go build -v ./...
|
|
|
|
- name: go vet
|
|
run: go vet ./...
|
|
|
|
- name: gofmt check
|
|
run: test -z "$(gofmt -l .)" || (echo "gofmt issues found:" && gofmt -l . && exit 1)
|
|
|
|
- name: go test
|
|
run: go test -v ./...
|
|
|
|
build:
|
|
needs: test
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: registry.rznet.fr/tchivert/ubuntu:act-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0 # all history for all branches and tags
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v4
|
|
|
|
- name: Login to registry
|
|
uses: docker/login-action@v4
|
|
with:
|
|
registry: git.rznet.fr
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v4
|
|
env:
|
|
ACTIONS_RUNTIME_TOKEN: '' # See https://gitea.com/gitea/act_runner/issues/119
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile
|
|
platforms: |
|
|
linux/amd64
|
|
linux/arm64
|
|
push: true
|
|
tags: git.rznet.fr/${{ github.repository }}:latest
|