mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-07-28 01:27:58 +00:00
chore(docker): reorganize docker files and add first-run entrypoint (#812)
* chore(docker): move Dockerfile into docker/ directory Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(docker): add entrypoint script to goreleaser Dockerfile - entrypoint.sh: on first run (config and workspace both absent) runs picoclaw onboard then exits for the user to configure; subsequent starts exec picoclaw gateway directly - Dockerfile.goreleaser: copy and use entrypoint.sh, run as root - .goreleaser.yaml: update dockerfile path, add entrypoint.sh to extra_files so it is included in the docker build context Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * chore(docker): update docker-compose to use pre-built image and bind mount - Use docker.io/sipeed/picoclaw:latest instead of building locally - Replace named volume with bind mount ./data:/root/.picoclaw - Move docker-compose.yml into docker/ directory Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * docs: update Docker Compose section to reflect new docker/ layout - Use docker compose -f docker/docker-compose.yml for all commands - Update setup flow: first run generates docker/data/config.json, container exits, user edits config, then restarts - Replace "Rebuild" section with "Update" (docker pull) since the compose file now uses the pre-built sipeed/picoclaw image - Apply same changes to README.zh.md Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(docker): use restart: on-failure to prevent restart after first-run setup unless-stopped restarts the container regardless of exit code, causing an infinite loop when entrypoint exits 0 after the initial onboard. on-failure only restarts on non-zero exit (i.e. crashes), so the container stays stopped after setup until the user restarts it manually. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * docs: sync Docker Compose section across all language READMEs Apply the same updates as the English/Chinese READMEs: - Use docker compose -f docker/docker-compose.yml for all commands - Update setup flow to first-run auto-config pattern - Replace build/rebuild section with update via docker pull - Affected: README.fr.md, README.ja.md, README.pt-br.md, README.vi.md Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
# ============================================================
|
||||
# Stage 1: Build the picoclaw binary
|
||||
# ============================================================
|
||||
FROM golang:1.25-alpine AS builder
|
||||
|
||||
RUN apk add --no-cache git make
|
||||
|
||||
WORKDIR /src
|
||||
|
||||
# Cache dependencies
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
|
||||
# Copy source and build
|
||||
COPY . .
|
||||
RUN make build
|
||||
|
||||
# ============================================================
|
||||
# Stage 2: Minimal runtime image
|
||||
# ============================================================
|
||||
FROM alpine:3.23
|
||||
|
||||
RUN apk add --no-cache ca-certificates tzdata curl
|
||||
|
||||
# Health check
|
||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
||||
CMD wget -q --spider http://localhost:18790/health || exit 1
|
||||
|
||||
# Copy binary
|
||||
COPY --from=builder /src/build/picoclaw /usr/local/bin/picoclaw
|
||||
|
||||
# Create non-root user and group
|
||||
RUN addgroup -g 1000 picoclaw && \
|
||||
adduser -D -u 1000 -G picoclaw picoclaw
|
||||
|
||||
# Switch to non-root user
|
||||
USER picoclaw
|
||||
|
||||
# Run onboard to create initial directories and config
|
||||
RUN /usr/local/bin/picoclaw onboard
|
||||
|
||||
ENTRYPOINT ["picoclaw"]
|
||||
CMD ["gateway"]
|
||||
@@ -0,0 +1,12 @@
|
||||
FROM alpine:3.21
|
||||
|
||||
ARG TARGETPLATFORM
|
||||
|
||||
RUN apk add --no-cache ca-certificates tzdata
|
||||
|
||||
COPY $TARGETPLATFORM/picoclaw /usr/local/bin/picoclaw
|
||||
COPY docker/entrypoint.sh /entrypoint.sh
|
||||
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
@@ -0,0 +1,34 @@
|
||||
services:
|
||||
# ─────────────────────────────────────────────
|
||||
# PicoClaw Agent (one-shot query)
|
||||
# docker compose -f docker/docker-compose.yml run --rm picoclaw-agent -m "Hello"
|
||||
# ─────────────────────────────────────────────
|
||||
picoclaw-agent:
|
||||
image: docker.io/sipeed/picoclaw:latest
|
||||
container_name: picoclaw-agent
|
||||
profiles:
|
||||
- agent
|
||||
# Uncomment to access host network; leave commented unless needed.
|
||||
#extra_hosts:
|
||||
# - "host.docker.internal:host-gateway"
|
||||
volumes:
|
||||
- ./data:/root/.picoclaw
|
||||
entrypoint: ["picoclaw", "agent"]
|
||||
stdin_open: true
|
||||
tty: true
|
||||
|
||||
# ─────────────────────────────────────────────
|
||||
# PicoClaw Gateway (Long-running Bot)
|
||||
# docker compose -f docker/docker-compose.yml up picoclaw-gateway
|
||||
# ─────────────────────────────────────────────
|
||||
picoclaw-gateway:
|
||||
image: docker.io/sipeed/picoclaw:latest
|
||||
container_name: picoclaw-gateway
|
||||
restart: on-failure
|
||||
profiles:
|
||||
- gateway
|
||||
# Uncomment to access host network; leave commented unless needed.
|
||||
#extra_hosts:
|
||||
# - "host.docker.internal:host-gateway"
|
||||
volumes:
|
||||
- ./data:/root/.picoclaw
|
||||
@@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
# First-run: neither config nor workspace exists.
|
||||
# If config.json is already mounted but workspace is missing we skip onboard to
|
||||
# avoid the interactive "Overwrite? (y/n)" prompt hanging in a non-TTY container.
|
||||
if [ ! -d "${HOME}/.picoclaw/workspace" ] && [ ! -f "${HOME}/.picoclaw/config.json" ]; then
|
||||
picoclaw onboard
|
||||
echo ""
|
||||
echo "First-run setup complete."
|
||||
echo "Edit ${HOME}/.picoclaw/config.json (add your API key, etc.) then restart the container."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
exec picoclaw gateway "$@"
|
||||
Reference in New Issue
Block a user