- Updated configuration and deployment files - Improved system architecture and components - Enhanced documentation and testing - Fixed various issues and added new features 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
69 lines
1.7 KiB
Docker
69 lines
1.7 KiB
Docker
# Minimal BZZZ Docker container without systemd
|
|
# Uses multi-stage build for smaller final image
|
|
FROM golang:1.21-alpine AS builder
|
|
|
|
WORKDIR /build
|
|
COPY go.mod go.sum ./
|
|
RUN go mod download
|
|
|
|
COPY . .
|
|
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags='-w -s -extldflags "-static"' -o bzzz .
|
|
|
|
# Final minimal image
|
|
FROM alpine:3.18
|
|
|
|
# Install only essential packages
|
|
RUN apk --no-cache add \
|
|
ca-certificates \
|
|
tzdata \
|
|
curl
|
|
|
|
# Create non-root user for security
|
|
RUN addgroup -g 1000 bzzz && \
|
|
adduser -u 1000 -G bzzz -s /bin/sh -D bzzz
|
|
|
|
# Create required directories
|
|
RUN mkdir -p /app/data /app/config /app/logs && \
|
|
chown -R bzzz:bzzz /app
|
|
|
|
# Copy binary from builder stage
|
|
COPY --from=builder /build/bzzz /app/bzzz
|
|
RUN chmod +x /app/bzzz
|
|
|
|
# Copy config template
|
|
COPY dockerize/config.minimal.yml.tmpl /app/config/config.yml.tmpl
|
|
|
|
# Create entrypoint script that handles config generation
|
|
RUN cat > /app/entrypoint.sh << 'EOF'
|
|
#!/bin/sh
|
|
set -e
|
|
|
|
# Generate config from template if it doesn't exist
|
|
if [ ! -f /app/config/config.yml ]; then
|
|
echo "🔧 Generating configuration from template..."
|
|
envsubst < /app/config/config.yml.tmpl > /app/config/config.yml
|
|
fi
|
|
|
|
# Ensure proper ownership
|
|
chown -R bzzz:bzzz /app/data /app/config /app/logs
|
|
|
|
echo "🚀 Starting BZZZ..."
|
|
exec "$@"
|
|
EOF
|
|
|
|
RUN chmod +x /app/entrypoint.sh
|
|
|
|
# Switch to non-root user
|
|
USER bzzz
|
|
WORKDIR /app
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
|
CMD curl -f http://localhost:8081/health || exit 1
|
|
|
|
# Expose ports
|
|
EXPOSE 8080 8081 9000-9100
|
|
|
|
# Set entrypoint and default command
|
|
ENTRYPOINT ["/app/entrypoint.sh"]
|
|
CMD ["/app/bzzz", "--config", "/app/config/config.yml"] |