Files
Docwell/Docker-AIO/Dockerfile.seaweedfs.split
tajniak81andClaude Opus 5.5 f7a2ded680
CI / go (Media) (push) Successful in 13m22s
CI / go (Server) (push) Failing after 24m20s
CI / go (Web-App) (push) Successful in 14m3s
CI / frontend (push) Failing after 9m19s
CI / mobile (push) Failing after 6m19s
CI / docker (push) Successful in 20m37s
CI / desktop (ubuntu-latest) (push) Successful in 1h9m43s
CI / desktop (macos-latest) (push) Canceled after 0s
CI / desktop (windows-latest) (push) Canceled after 0s
Give the all-in-one setup every storage shape, from source and baked in
Docker-AIO now has one compose file per storage shape for each way of
getting the image, each with an .env template of the same name:
- From source: docker-compose.yml (now with .env.example),
  docker-compose.s3.yml, docker-compose.seaweedfs.yml and
  docker-compose.seaweedfs.split.yml. The SeaweedFS ones run it in
  containers beside the plain image, as the prod files did before.
- Production: docker-compose.prod.seaweedfs*.yml now run one container
  from new images with SeaweedFS built in. Dockerfile.seaweedfs runs
  `weed server -s3`; Dockerfile.seaweedfs.split runs master, volume,
  filer, S3 gateway and admin UI as separate processes, and seeds
  PocketBase's key into the filer's IAM store so the admin UI cannot
  displace it.

SeaweedFS listens on the container's loopback (volume server on 8081,
as docwell-server has 8080); only the split image's admin UI is
published, on loopback by default. start.sh now also watches the
processes a wrapper started, so the container restarts as a whole when
any SeaweedFS role stops. The release workflow publishes the two new
images, docwell-seaweedfs and docwell-seaweedfs-split.

Existing SeaweedFS installs keep their data: every file uses the
`weed server -dir` layout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 19:29:46 +01:00

121 lines
6.1 KiB
Docker

# Docwell all-in-one WITH the object store inside: PocketBase + docwell-server
# + docwell-web, plus SeaweedFS split into its roles (master, volume, filer, S3
# gateway and the admin UI), each its own process in the same container.
#
# This is Dockerfile with the six SeaweedFS containers of
# docker-compose.seaweedfs.split.yml folded in. Those keep SeaweedFS outside the
# image so it can be upgraded with a tag change; this file trades that for one
# image and one container. What the split still buys in here: per-role metrics
# ports and the admin UI, where S3 identities are minted and revoked. What it
# costs: a new SeaweedFS is a rebuild (--build-arg SEAWEED_VERSION).
#
# Build from the repository root:
# docker build -f Docker-AIO/Dockerfile.seaweedfs.split -t docwell-aio-seaweedfs-split .
#
# Run it:
# docker run -d -p 3000:3000 -p 127.0.0.1:23646:23646 \
# -e PB_ADMIN_EMAIL=admin@example.com -e PB_ADMIN_PASSWORD=change-me \
# -e DOCWELL_S3_ACCESS_KEY=... -e DOCWELL_S3_SECRET=... \
# -e WEED_ADMIN_PASSWORD=change-me \
# -v docwell_pb:/pb_data -v docwell_seaweed:/seaweed/data \
# -v docwell_seaweed_admin:/seaweed/admin docwell-aio-seaweedfs-split
#
# Ports inside the container (only 3000 and 23646 are meant to be published;
# every SeaweedFS role but the admin UI listens on loopback):
# 3000 docwell-web (app, /api, /collab, /admin)
# 8070 PocketBase (loopback)
# 8080 docwell-server (loopback) <- why the volume server is on 8081
# 8081 SeaweedFS volume (loopback; serves files by id, no auth)
# 8333 SeaweedFS S3 gateway (loopback; PocketBase's endpoint)
# 8888 SeaweedFS filer (loopback)
# 9333 SeaweedFS master (loopback)
# 23646 SeaweedFS admin UI
# Multi-arch: build stages run on the build machine's platform and Go
# cross-compiles, so arm64 images build without emulation.
# SeaweedFS to bake in, pinned so a rebuild later brings up the same one; the
# same tag the compose files run as SEAWEED_IMAGE. Declared before the first
# FROM because a FROM can only use a global ARG.
ARG SEAWEED_VERSION=4.45
FROM --platform=$BUILDPLATFORM node:24-alpine AS ui
WORKDIR /src
COPY package.json package-lock.json tsconfig.base.json ./
COPY Packages/ Packages/
COPY Server/admin/ Server/admin/
COPY Web-App/frontend/ Web-App/frontend/
COPY Desktop-App/frontend/package.json Desktop-App/frontend/
RUN npm ci --no-audit --no-fund
RUN mkdir -p Server/internal/admin/dist Web-App/internal/spa/dist \
&& npm run build -w @docwell/admin \
&& npm run build -w @docwell/web-app
# yrs (Rust Yjs) compiled to WebAssembly; the server embeds it (ADR-3).
FROM --platform=$BUILDPLATFORM rust:1-alpine AS yrs
RUN rustup target add wasm32-wasip1
WORKDIR /src
COPY Server/ycrdt-wasm/ ./
RUN cargo build --locked --release --target wasm32-wasip1
FROM --platform=$BUILDPLATFORM golang:1.26-alpine AS build
ARG TARGETOS TARGETARCH
WORKDIR /src
COPY Server/ Server/
COPY Web-App/ Web-App/
COPY --from=ui /src/Server/internal/admin/dist Server/internal/admin/dist
COPY --from=yrs /src/target/wasm32-wasip1/release/docwell_yrs.wasm Server/internal/ycrdt/docwell_yrs.wasm
COPY --from=ui /src/Web-App/internal/spa/dist Web-App/internal/spa/dist
ARG VERSION=dev
ENV CGO_ENABLED=0 GOWORK=off GOOS=$TARGETOS GOARCH=$TARGETARCH
RUN cd Server && go build -trimpath -ldflags "-s -w -X main.Version=${VERSION}" -o /out/docwell-server ./cmd/docwell-server
RUN cd Web-App && go build -trimpath -ldflags "-s -w -X main.Version=${VERSION}" -o /out/docwell-web ./cmd/docwell-web
# The one static weed binary from the official image, for the target platform.
FROM chrislusf/seaweedfs:${SEAWEED_VERSION} AS seaweed
FROM alpine:3.22
ARG PB_VERSION=0.40.6
ARG TARGETARCH
# ffmpeg cuts long recordings for transcription (ADR-15).
RUN apk add --no-cache ca-certificates unzip wget ffmpeg \
&& wget -q "https://github.com/pocketbase/pocketbase/releases/download/v${PB_VERSION}/pocketbase_${PB_VERSION}_linux_${TARGETARCH:-amd64}.zip" -O /tmp/pb.zip \
&& unzip /tmp/pb.zip pocketbase -d /usr/local/bin && rm /tmp/pb.zip && apk del unzip
COPY --from=build /out/ /usr/local/bin/
COPY --from=seaweed /usr/bin/weed /usr/local/bin/weed
# No migrations or hooks: docwell-server applies Docwell's schema and the
# DOCWELL_* settings to PocketBase when it starts. start-seaweedfs-split.sh starts SeaweedFS,
# then execs start.sh, which runs the rest and watches every process.
COPY Docker-AIO/start.sh /start.sh
COPY Docker-AIO/start-seaweedfs-split.sh /start-seaweedfs-split.sh
RUN chmod +x /start.sh /start-seaweedfs-split.sh && mkdir -p /data /seaweed/data /seaweed/admin
# /data holds the search index, which is rebuilt from PocketBase when missing.
#
# File storage is on by construction: the gateway is in this image at a fixed
# loopback address, path style because a self-hosted gateway has no per-bucket
# DNS. docwell-server writes these into PocketBase on every start. Only uploaded
# files move to the bucket; the database and PocketBase's backups stay in
# /pb_data. Required at runtime: PB_ADMIN_EMAIL, PB_ADMIN_PASSWORD,
# DOCWELL_S3_ACCESS_KEY, DOCWELL_S3_SECRET and WEED_ADMIN_PASSWORD.
ENV DOCWELL_DATA_DIR=/data \
DOCWELL_S3_ENABLED=true \
DOCWELL_S3_ENDPOINT=http://127.0.0.1:8333 \
DOCWELL_S3_BUCKET=docwell \
DOCWELL_S3_REGION=us-east-1 \
DOCWELL_S3_FORCE_PATH_STYLE=true \
WEED_ADMIN_USER=admin
# /seaweed/data is the `weed server -dir` layout, shared by master, volume and
# filer, so a volume moves between Dockerfile.seaweedfs, Dockerfile.seaweedfs.split
# and the compose files' SeaweedFS containers unchanged.
# /seaweed/admin: the admin UI's session key and maintenance settings.
VOLUME /pb_data /data /seaweed/data /seaweed/admin
EXPOSE 3000 23646
HEALTHCHECK --interval=10s --timeout=5s --start-period=60s --retries=5 \
CMD wget -qO- http://127.0.0.1:9333/cluster/status >/dev/null \
&& wget -qO- http://127.0.0.1:8081/healthz >/dev/null \
&& wget -qO- http://127.0.0.1:8888/healthz >/dev/null \
&& wget -qO- http://127.0.0.1:8333/healthz >/dev/null \
&& wget -qO- http://127.0.0.1:23646/health >/dev/null \
&& wget -qO- http://127.0.0.1:3000/api/v1/version >/dev/null || exit 1
ENTRYPOINT ["/start-seaweedfs-split.sh"]