Files
meshcore-bot/Dockerfile
agessaman 61445b4811 feat: Update README and .gitignore for Docker deployment
- Added Docker deployment instructions to the README, including steps for creating data directories, updating configuration paths, and starting the application with Docker Compose.
- Updated .gitignore to include a new data directory structure, ensuring user-specific configurations, databases, and logs are ignored while maintaining the directory structure.
2026-01-17 08:34:38 -08:00

58 lines
1.5 KiB
Docker

# Multi-stage build for meshcore-bot
FROM python:3.11-slim as builder
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /build
# Copy dependency files
COPY requirements.txt pyproject.toml ./
# Install Python dependencies
RUN pip install --no-cache-dir --user -r requirements.txt
# Final stage
FROM python:3.11-slim
# Install runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
# For serial port access
udev \
# For BLE support (optional, but commonly needed)
libbluetooth3 \
# Cleanup
&& rm -rf /var/lib/apt/lists/*
# Create non-root user
RUN useradd -m -u 1000 meshcore && \
mkdir -p /app /data/config /data/databases /data/logs /data/backups && \
chown -R meshcore:meshcore /app /data
# Copy Python dependencies from builder
COPY --from=builder /root/.local /home/meshcore/.local
# Set working directory
WORKDIR /app
# Copy application files
COPY --chown=meshcore:meshcore . /app/
# Set PATH to include user's local bin
ENV PATH=/home/meshcore/.local/bin:$PATH \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1
# Switch to non-root user
USER meshcore
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD python3 -c "import sys; sys.exit(0)" || exit 1
# Default command
CMD ["python3", "meshcore_bot.py", "--config", "/data/config/config.ini"]