# rdev-worker - Standalone worker for the rdev platform
# Runs as a standalone container with a claudebox sidecar for execution.

# Build stage
FROM golang:1.25-alpine AS builder
WORKDIR /build
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o rdev-worker ./cmd/rdev-worker

# Runtime stage - minimal Alpine image
FROM alpine:3.19

# Install ca-certificates for HTTPS
RUN apk add --no-cache ca-certificates

# Copy worker binary
COPY --from=builder /build/rdev-worker /usr/local/bin/rdev-worker

# Create non-root user
RUN adduser -D -u 1000 worker
USER worker

# Default environment
ENV RDEV_API_URL="http://rdev-api.rdev.svc.cluster.local:8080"
ENV CLAUDEBOX_URL="http://localhost:8080"
ENV WORKER_POLL_INTERVAL="5s"

# Run worker
CMD ["rdev-worker"]
