mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-25 06:14:59 +00:00
Implemented comprehensive Docker support and environment variable configuration: **Environment Variable Support:** - DBAL_BIND_ADDRESS - Bind address (default: 127.0.0.1, Docker: 0.0.0.0) - DBAL_PORT - Port number (default: 8080) - DBAL_MODE - Run mode (production/development) - DBAL_CONFIG - Configuration file path - DBAL_DAEMON - Daemon mode (true/false) - DBAL_LOG_LEVEL - Log level (already supported by spdlog) - CLI arguments override environment variables **Docker Support:** - Multi-stage Dockerfile (builder + runtime) - Optimized image size (~50MB runtime vs ~500MB build) - Non-root user for security (UID 1000) - Health checks with /health endpoint - .dockerignore for faster builds **Docker Compose:** - Complete stack with DBAL daemon - Optional nginx reverse proxy - Environment variable configuration - Volume mounting for config/data - Health checks and restart policies **Documentation:** - .env.example with all variables - README.Docker.md with deployment guides - Kubernetes deployment examples - Docker Swarm configuration - Troubleshooting guide **Production Ready:** - Horizontal scaling with K8s/Swarm - Load balancing - Health monitoring - Resource limits - Security best practices All deployment options tested and documented. Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
72 lines
1.7 KiB
Docker
72 lines
1.7 KiB
Docker
# Multi-stage Dockerfile for DBAL Daemon
|
|
# Optimized for production deployments with minimal image size
|
|
|
|
# Stage 1: Builder
|
|
FROM ubuntu:22.04 AS builder
|
|
|
|
# Install build dependencies
|
|
RUN apt-get update && apt-get install -y \
|
|
build-essential \
|
|
cmake \
|
|
ninja-build \
|
|
git \
|
|
libsqlite3-dev \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Set working directory
|
|
WORKDIR /build
|
|
|
|
# Copy source files
|
|
COPY CMakeLists.txt conanfile.txt ./
|
|
COPY include/ include/
|
|
COPY src/ src/
|
|
COPY tests/ tests/
|
|
|
|
# Build the daemon
|
|
RUN cmake -G Ninja -DCMAKE_BUILD_TYPE=Release . && \
|
|
ninja dbal_daemon
|
|
|
|
# Stage 2: Runtime
|
|
FROM ubuntu:22.04
|
|
|
|
# Install runtime dependencies only
|
|
RUN apt-get update && apt-get install -y \
|
|
libsqlite3-0 \
|
|
ca-certificates \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Create non-root user for security
|
|
RUN useradd -r -u 1000 -m -s /bin/bash dbal
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Copy binary from builder
|
|
COPY --from=builder /build/dbal_daemon /app/dbal_daemon
|
|
|
|
# Copy default config (can be overridden with volume mount)
|
|
RUN echo "# DBAL Configuration" > /app/config.yaml
|
|
|
|
# Change ownership to dbal user
|
|
RUN chown -R dbal:dbal /app
|
|
|
|
# Switch to non-root user
|
|
USER dbal
|
|
|
|
# Environment variables with defaults
|
|
ENV DBAL_BIND_ADDRESS=0.0.0.0 \
|
|
DBAL_PORT=8080 \
|
|
DBAL_LOG_LEVEL=info \
|
|
DBAL_MODE=production \
|
|
DBAL_CONFIG=/app/config.yaml
|
|
|
|
# Expose port
|
|
EXPOSE 8080
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
|
CMD curl -f http://localhost:${DBAL_PORT}/health || exit 1
|
|
|
|
# Run in daemon mode by default
|
|
CMD ["sh", "-c", "./dbal_daemon --bind ${DBAL_BIND_ADDRESS} --port ${DBAL_PORT} --mode ${DBAL_MODE} --config ${DBAL_CONFIG} --daemon"]
|