CI / Test (ubuntu-latest) (push) Canceled after 0s
CI / Test (windows-latest) (push) Canceled after 0s
CI / Storage tests on PostgreSQL (push) Canceled after 0s
CI / Complement (federation off) (push) Canceled after 0s
CI / golangci-lint (push) Canceled after 0s
CI / Smoke test the binary (push) Canceled after 0s
Implements PLAN.md Phase 6: the media repository. Clients upload files, reserve an mxc:// URI and upload to it later, download and ask for thumbnails, all through the authenticated media endpoints of Matrix 1.11; other servers download this server's media through the federation media endpoints, and media uploaded elsewhere is fetched over federation on first use and kept. internal/mediaapi is the component. Content goes into a BlobStore named by its SHA-256, so the same file uploaded twice is stored once and the hash doubles as the ETag; the metadata that maps an mxc:// URI onto a blob is in media_repository and media_thumbnails. The local-filesystem store writes to a temporary file and renames it into place once hashed, so nothing ever refers to half a file. A storage driver can bring its own store through storage.BlobProvider, which is where PocketBase's filesystem abstraction (local or S3) plugs in with Phase 10. Reserved uploads belong to the user who made them, take one upload, lapse after a day, and are capped per user; a download of one waits for its content, woken in memory the moment it arrives, for as long as timeout_ms allows. Thumbnails come from a fixed set of configured sizes, so a thousand requested sizes cannot mean a thousand resizes. They are made on first request and kept, never enlarge, honour a JPEG's EXIF orientation, and point at the original when it already fits. The pixel count is checked from the header before anything is decoded, at most four resizes run at once, and concurrent requests for the same thumbnail share one. Remote media is fetched through the signed client: the multipart/mixed answer of Matrix 1.11, with a fallback to the legacy download endpoint for servers that answer M_UNRECOGNIZED, and Location redirects followed by a dialer that refuses loopback, private and link-local addresses. Concurrent requests share one fetch, detached from the request that started it. With federation off nothing is fetched, and what was cached before is still served. Downloads carry a sandboxing CSP, nosniff, inline Content-Disposition only for the types the spec lists as safe, and private immutable caching. The unauthenticated legacy download endpoints are off by default behind media.legacy_unauthenticated_downloads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
57 lines
1.6 KiB
Docker
57 lines
1.6 KiB
Docker
# Warp homeserver — single binary, no cgo.
|
|
#
|
|
# docker build -t warp .
|
|
# docker run -p 8008:8008 -v warp-data:/data \
|
|
# -e WARP_SERVER_NAME=warp.example warp
|
|
|
|
FROM golang:1.26-alpine AS build
|
|
|
|
WORKDIR /src
|
|
|
|
# Dependencies first, so the module cache survives source changes.
|
|
COPY server/go.mod server/go.sum ./server/
|
|
RUN cd server && go mod download
|
|
|
|
COPY server ./server
|
|
|
|
ARG VERSION=0.0.0-dev
|
|
ARG COMMIT=unknown
|
|
ARG BUILD_DATE=unknown
|
|
|
|
ENV CGO_ENABLED=0
|
|
RUN cd server && go build -trimpath \
|
|
-ldflags "-s -w \
|
|
-X github.com/dariuszjaniak/warp/server/internal/buildinfo.Version=${VERSION} \
|
|
-X github.com/dariuszjaniak/warp/server/internal/buildinfo.Commit=${COMMIT} \
|
|
-X github.com/dariuszjaniak/warp/server/internal/buildinfo.BuildDate=${BUILD_DATE}" \
|
|
-o /out/warp ./cmd/warp
|
|
|
|
|
|
FROM alpine:3.21
|
|
|
|
RUN apk add --no-cache ca-certificates tzdata curl && \
|
|
adduser -D -u 10001 -h /data warp
|
|
|
|
COPY --from=build /out/warp /usr/local/bin/warp
|
|
COPY warp.yaml.example /etc/warp/warp.yaml.example
|
|
|
|
# Database file, signing key and media live here; mount a volume on it.
|
|
WORKDIR /data
|
|
RUN chown warp:warp /data
|
|
USER warp
|
|
|
|
ENV WARP_LISTEN_ADDRESS=":8008" \
|
|
WARP_PRIVATE_KEY="/data/signing.key" \
|
|
WARP_DB_DRIVER="sqlite" \
|
|
WARP_DB_CONNECTION_STRING="file:/data/warp.db?_pragma=journal_mode(WAL)&_pragma=busy_timeout(10000)&_pragma=foreign_keys(1)" \
|
|
WARP_MEDIA_BASE_PATH="/data/media" \
|
|
WARP_LOG_FORMAT="json"
|
|
|
|
EXPOSE 8008
|
|
|
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
|
|
CMD curl -fsS http://127.0.0.1:8008/healthz || exit 1
|
|
|
|
ENTRYPOINT ["warp"]
|
|
CMD ["serve"]
|