Files
vstats/Dockerfile.agent.prebuilt
zsai001 182509ac5c feat: add Docker support for agent
- Add Dockerfile.agent for building agent from source
- Add Dockerfile.agent.prebuilt for CI/CD pipeline
- Add docker-compose.agent.yml for easy deployment
- Add environment variable support to agent config
- Update GitHub Actions to build and push agent Docker image
- Update README with agent Docker deployment instructions
2025-12-06 14:36:46 +08:00

46 lines
1.2 KiB
Docker

# Dockerfile for pre-built agent binaries (used in CI/CD)
# This dockerfile expects the binary to be copied into the build context
FROM alpine:latest
ARG TARGETARCH
WORKDIR /app
# Install ca-certificates for HTTPS and tzdata for timezone support
RUN apk add --no-cache ca-certificates tzdata
# Create non-root user
RUN addgroup -g 1000 vstats && \
adduser -D -u 1000 -G vstats vstats
# Copy pre-built binary (architecture-specific)
COPY vstats-agent-linux-${TARGETARCH} /app/vstats-agent
RUN chmod +x /app/vstats-agent
# Create config directory
RUN mkdir -p /opt/vstats-agent && \
chown -R vstats:vstats /app /opt/vstats-agent
# Environment variables for configuration
# These can be overridden at runtime
ENV VSTATS_DASHBOARD_URL=""
ENV VSTATS_SERVER_ID=""
ENV VSTATS_AGENT_TOKEN=""
ENV VSTATS_SERVER_NAME=""
ENV VSTATS_LOCATION=""
ENV VSTATS_PROVIDER=""
ENV VSTATS_INTERVAL_SECS="5"
ENV VSTATS_CONFIG_PATH="/opt/vstats-agent/config.json"
# Health check - verify the binary works
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
CMD /app/vstats-agent version > /dev/null 2>&1 || exit 1
# Run as vstats user
USER vstats
# Run the agent
CMD ["/app/vstats-agent", "run", "--config", "/opt/vstats-agent/config.json"]