mirror of
https://github.com/latinogino/dolibarr-mcp.git
synced 2026-04-24 02:25:35 +02:00
Align structure with prestashop-mcp
This commit is contained in:
76
docker/Dockerfile
Normal file
76
docker/Dockerfile
Normal file
@@ -0,0 +1,76 @@
|
||||
# Multi-stage Docker build for Dolibarr MCP Server
|
||||
FROM python:3.11-slim as builder
|
||||
|
||||
# Set environment variables
|
||||
ENV PYTHONUNBUFFERED=1 \
|
||||
PYTHONDONTWRITEBYTECODE=1 \
|
||||
PIP_NO_CACHE_DIR=1 \
|
||||
PIP_DISABLE_PIP_VERSION_CHECK=1
|
||||
|
||||
# Install build dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
build-essential \
|
||||
curl \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Create working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Copy dependency files
|
||||
COPY requirements.txt pyproject.toml ./
|
||||
|
||||
# Install Python dependencies
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# Copy source code
|
||||
COPY src/ ./src/
|
||||
COPY README.md LICENSE ./
|
||||
|
||||
# Install the package
|
||||
RUN pip install -e .
|
||||
|
||||
# Production stage
|
||||
FROM python:3.11-slim as production
|
||||
|
||||
# Set environment variables
|
||||
ENV PYTHONUNBUFFERED=1 \
|
||||
PYTHONDONTWRITEBYTECODE=1 \
|
||||
PATH="/opt/venv/bin:$PATH"
|
||||
|
||||
# Create non-root user
|
||||
RUN groupadd -r dolibarr && useradd -r -g dolibarr dolibarr
|
||||
|
||||
# Install runtime dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
curl \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Copy installed packages from builder
|
||||
COPY --from=builder /usr/local/lib/python3.11/site-packages/ /usr/local/lib/python3.11/site-packages/
|
||||
COPY --from=builder /usr/local/bin/ /usr/local/bin/
|
||||
COPY --from=builder /app/src/ /app/src/
|
||||
|
||||
# Create working directory and set ownership
|
||||
WORKDIR /app
|
||||
RUN chown -R dolibarr:dolibarr /app
|
||||
|
||||
# Switch to non-root user
|
||||
USER dolibarr
|
||||
|
||||
# Health check using test command
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
||||
CMD python -m dolibarr_mcp.cli test || exit 1
|
||||
|
||||
# Expose port (for future HTTP interface)
|
||||
EXPOSE 8080
|
||||
|
||||
# Default command runs the MCP server
|
||||
CMD ["python", "-m", "dolibarr_mcp"]
|
||||
|
||||
# Labels for metadata
|
||||
LABEL org.opencontainers.image.title="Dolibarr MCP Server" \
|
||||
org.opencontainers.image.description="Professional Model Context Protocol server for Dolibarr ERP integration" \
|
||||
org.opencontainers.image.url="https://github.com/latinogino/dolibarr-mcp" \
|
||||
org.opencontainers.image.source="https://github.com/latinogino/dolibarr-mcp" \
|
||||
org.opencontainers.image.version="1.0.1" \
|
||||
org.opencontainers.image.licenses="MIT"
|
||||
93
docker/docker-compose.yml
Normal file
93
docker/docker-compose.yml
Normal file
@@ -0,0 +1,93 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
dolibarr-mcp:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
image: dolibarr-mcp:latest
|
||||
container_name: dolibarr-mcp-server
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
# Dolibarr API Configuration
|
||||
- DOLIBARR_URL=${DOLIBARR_URL:-https://your-dolibarr-instance.com/api/index.php}
|
||||
- DOLIBARR_API_KEY=${DOLIBARR_API_KEY:-your_api_key_here}
|
||||
|
||||
# Logging Configuration
|
||||
- LOG_LEVEL=${LOG_LEVEL:-INFO}
|
||||
- PYTHONUNBUFFERED=1
|
||||
|
||||
# MCP Server Configuration
|
||||
- MCP_SERVER_NAME=dolibarr-mcp
|
||||
- MCP_SERVER_VERSION=1.0.0
|
||||
|
||||
volumes:
|
||||
# Mount configuration if needed
|
||||
- ./.env:/app/.env:ro
|
||||
|
||||
# Optional: Mount for custom configurations or plugins
|
||||
# - ./config:/app/config:ro
|
||||
# - ./plugins:/app/plugins:ro
|
||||
|
||||
# Expose port for future HTTP interface
|
||||
ports:
|
||||
- "8080:8080"
|
||||
|
||||
# Health check
|
||||
healthcheck:
|
||||
test: ["CMD", "python", "-c", "import sys; from src.dolibarr_mcp.config import Config; sys.exit(0 if Config().api_key else 1)"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 10s
|
||||
|
||||
# Resource limits
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '1.0'
|
||||
memory: 512M
|
||||
reservations:
|
||||
cpus: '0.25'
|
||||
memory: 128M
|
||||
|
||||
# Logging
|
||||
logging:
|
||||
driver: "json-file"
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
|
||||
networks:
|
||||
- dolibarr-mcp-network
|
||||
|
||||
# Optional: Include a test service
|
||||
dolibarr-mcp-test:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
image: dolibarr-mcp:latest
|
||||
container_name: dolibarr-mcp-test
|
||||
environment:
|
||||
- DOLIBARR_URL=${DOLIBARR_URL}
|
||||
- DOLIBARR_API_KEY=${DOLIBARR_API_KEY}
|
||||
- LOG_LEVEL=DEBUG
|
||||
volumes:
|
||||
- ./.env:/app/.env:ro
|
||||
- ./test_dolibarr_mcp.py:/app/test_dolibarr_mcp.py:ro
|
||||
command: python /app/test_dolibarr_mcp.py
|
||||
profiles:
|
||||
- test
|
||||
networks:
|
||||
- dolibarr-mcp-network
|
||||
|
||||
networks:
|
||||
dolibarr-mcp-network:
|
||||
driver: bridge
|
||||
name: dolibarr-mcp-net
|
||||
|
||||
# To run the main server:
|
||||
# docker-compose up
|
||||
|
||||
# To run tests:
|
||||
# docker-compose --profile test up dolibarr-mcp-test
|
||||
Reference in New Issue
Block a user