Files
HugeFrog24 401b263991 Upgrade dependencies and toolchain; migrate to Claude API 2026-10-21
Toolchain and CI:
- Go 1.27 (go directive 1.27.0, CI 1.27.3)
- actions/checkout v7, actions/setup-go v7
- golangci-lint v2.15.0, gosec v2.30.0
- Dockerfile: drop obsolete -a -installsuffix cgo build flags

Go modules:
- anthropic-sdk-go v1.71.0 -> v2.3.0 (new /v2 module path, API version
  2026-10-21); go-telegram/bot v1.27.0; x/sync v0.24.0; indirects to latest
- BetaMessageParam is now a per-role union: build assistant turns with
  OfAssistant and read content through the role in the cache helper
- Pass the Anthropic API key only when set: v2 sends an explicitly passed
  credential as is, so an empty key became an empty bearer token instead of
  falling back to the SDK's default credential chain as v1 did

API 2026-10-21 / deprecations:
- Stop sending temperature (rejected on every model); the config key is
  still parsed and a startup notice flags it
- Name refusals in the empty-response error instead of reporting an
  unexpected response format
- ElevenLabs STT: scribe_v1 (deprecated) -> scribe_v2
- Template config: claude-haiku-5-5 with effort low, temperature removed

Docs: replace the unsupported `go get -u` install step, document the ignored
temperature key, default-on thinking, and per-model effort defaults.
2026-10-25 13:34:39 +01:00

55 lines
1.4 KiB
Docker

# Multi-stage build for Go Telegram Bot
# Build stage
FROM golang:1.27-alpine AS builder
# Install build dependencies including C compiler for CGO
RUN apk add --no-cache git ca-certificates tzdata gcc musl-dev
# Set working directory
WORKDIR /build
# Copy go mod files first for better caching
COPY go.mod go.sum ./
# Download dependencies
RUN go mod download
# Copy source code
COPY . .
# Build the application
RUN CGO_ENABLED=1 GOOS=linux go build -o telegram-bot .
# Runtime stage
FROM alpine:latest
# Merged into a single RUN to minimise image layers (docker:S7031).
# Order matters: packages must be installed before adduser/addgroup,
# and the app directory must exist before chown runs.
RUN apk --no-cache add ca-certificates tzdata sqlite && \
addgroup -g 1001 -S appgroup && \
adduser -u 1001 -S appuser -G appgroup && \
mkdir -p /app/config /app/data /app/logs && \
chown -R appuser:appgroup /app
# Set working directory
WORKDIR /app
# Copy binary from builder stage
COPY --from=builder /build/telegram-bot /app/telegram-bot
# Copy default config as template
COPY --chown=appuser:appgroup config/default.json /app/config/
# Switch to non-root user
USER appuser
# Expose any ports if needed (not required for this bot)
# EXPOSE 8080
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD pgrep telegram-bot || exit 1
# Run the application
CMD ["/app/telegram-bot"]