Spaces:
Runtime error
Runtime error
| # 1. Build Picoclaw Binary using Go Builder | |
| FROM golang:bookworm AS builder | |
| WORKDIR /build | |
| # Clone fresh or copy local (using remote github main branch for simplicity) | |
| RUN apt-get update && apt-get install -y git make | |
| RUN git clone https://github.com/sipeed/picoclaw.git . | |
| RUN make deps | |
| # Build the binary with CGO_ENABLED=1 so Go uses glibc for DNS (reads /etc/resolv.conf) | |
| # Strictly hardcode the APIServer because config seems to be lost inside the HF container | |
| RUN sed -i 's|bot, err := telego.NewBot(telegramCfg.Token, opts...)|opts = append(opts, telego.WithAPIServer("http://127.0.0.1:7860/tg")); bot, err := telego.NewBot(telegramCfg.Token, opts...)|g' pkg/channels/telegram/telegram.go | |
| RUN go generate ./... | |
| RUN CGO_ENABLED=1 go build -o /build/picoclaw-bin ./cmd/picoclaw | |
| # 2. Main Runtime Image using Playwright | |
| FROM mcr.microsoft.com/playwright:v1.58.2-jammy | |
| WORKDIR /app | |
| # Copy the compiled picoclaw binary from the builder | |
| COPY --from=builder /build/picoclaw-bin /app/picoclaw-bin | |
| RUN chmod +x /app/picoclaw-bin | |
| # DNS override happens at RUNTIME in server.js (resolv.conf is read-only during build) | |
| # Force Go to use cgo (glibc) DNS resolver which reads /etc/resolv.conf | |
| ENV GODEBUG=netdns=cgo | |
| # Set up the Node environment | |
| COPY package*.json ./ | |
| RUN npm install | |
| # Copy our proxy wrapper and the Gemini script | |
| COPY server.js ./ | |
| COPY GeminiWebAPI.cjs ./ | |
| # Copy the configuration template for Picoclaw | |
| COPY data /app/data | |
| # ALSO copy to the default Go lookup path as a fallback | |
| RUN mkdir -p /root/.picoclaw && cp /app/data/config.json /root/.picoclaw/config.json | |
| ENV PORT=7860 | |
| ENV PICOCLAW_CONFIG=/app/data/config.json | |
| ENV PICOCLAW_HOME=/app/data | |
| EXPOSE 7860 | |
| # We need elevated timeout for browser startups under heavy load | |
| ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright | |
| CMD ["npm", "start"] | |