Files
pipelines/Dockerfile
T
alan c810437aa5 Claude Code chats survive server restarts in a detachable host
A pipelines-claude-host process owns each claude -p CLI and its pipes,
spools its stream-json output with offsets and serves a private Unix
socket. The server detaches on shutdown and reattaches on start,
replaying the spool to rebuild turns, approvals, questions, background
tasks and the live model. Explicit close, idle release and CLI exit stop
the host; a crashed host falls back to --resume with a notice.
2026-11-04 16:09:56 +00:00

58 lines
3.0 KiB
Docker

# Defaults are the last verified reproducible pins. Setup overrides them with
# the current resolved release versions and immutable image digest; the moving
# `latest` tag and version-only references are never used. OPENCODE_DIGEST has
# no default so a bare build cannot silently fall back to a version tag.
ARG OPENCODE_IMAGE=ghcr.io/anomalyco/opencode
ARG OPENCODE_VERSION=2.0.26
ARG OPENCODE_DIGEST
ARG PI_VERSION=1.1.0
FROM golang:1.27-alpine AS build
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY . .
ARG PIPELINES_VERSION=dev
ARG PIPELINES_COMMIT=unknown
ARG PIPELINES_DIRTY=unknown
RUN CGO_ENABLED=0 go build -trimpath -ldflags "-X git.a-wan.net/alan/pipelines/internal/buildinfo.Version=${PIPELINES_VERSION} -X git.a-wan.net/alan/pipelines/internal/buildinfo.Commit=${PIPELINES_COMMIT} -X git.a-wan.net/alan/pipelines/internal/buildinfo.Dirty=${PIPELINES_DIRTY}" -o /out/pipelines-server ./cmd/pipelines-server
RUN CGO_ENABLED=0 go build -trimpath -ldflags "-X git.a-wan.net/alan/pipelines/internal/buildinfo.Version=${PIPELINES_VERSION} -X git.a-wan.net/alan/pipelines/internal/buildinfo.Commit=${PIPELINES_COMMIT} -X git.a-wan.net/alan/pipelines/internal/buildinfo.Dirty=${PIPELINES_DIRTY}" -o /out/pipelines ./cmd/pipelines
RUN CGO_ENABLED=0 go build -trimpath -o /out/pipelines-claude-host ./cmd/pipelines-claude-host
FROM ${OPENCODE_IMAGE}@${OPENCODE_DIGEST}
ARG OPENCODE_VERSION
ARG OPENCODE_DIGEST
ARG PI_VERSION
ARG PIPELINES_VERSION=dev
ARG PIPELINES_COMMIT=unknown
ARG PIPELINES_DIRTY=unknown
# Identity labels let setup verify the built image's actual source and harness
# pins without a running-container probe or trusting a sidecar receipt file.
LABEL net.a-wan.pipelines.opencode-version="${OPENCODE_VERSION}" \
net.a-wan.pipelines.opencode-digest="${OPENCODE_DIGEST}" \
net.a-wan.pipelines.pi-version="${PI_VERSION}" \
net.a-wan.pipelines.source-version="${PIPELINES_VERSION}" \
net.a-wan.pipelines.source-commit="${PIPELINES_COMMIT}" \
net.a-wan.pipelines.source-dirty="${PIPELINES_DIRTY}"
USER root
RUN apk add --no-cache ca-certificates tzdata git curl nodejs npm python3 \
&& npm install --global --ignore-scripts @earendil-works/pi-coding-agent@${PI_VERSION} \
&& addgroup -g 10001 pipelines \
&& adduser -D -u 10001 -G pipelines -h /home/pipelines pipelines \
&& mkdir -p /data /workspace \
&& chown -R pipelines:pipelines /data /workspace /home/pipelines
COPY --from=build /out/pipelines-server /usr/local/bin/pipelines-server
COPY --from=build /out/pipelines /usr/local/bin/pipelines
COPY --from=build /out/pipelines-claude-host /usr/local/bin/pipelines-claude-host
COPY --from=build /usr/local/go /usr/local/go
COPY --chown=10001:10001 . /workspace
ENV HOME=/home/pipelines \
PATH=/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
GOPATH=/home/pipelines/go \
CGO_ENABLED=0
WORKDIR /workspace
USER 10001:10001
EXPOSE 8080
ENTRYPOINT ["/usr/local/bin/pipelines-server"]
CMD ["-addr", "0.0.0.0:8080", "-db", "/data/pipelines.db"]