NoteDiscovery/Dockerfile

45 lines
1.3 KiB
Docker
Raw Normal View History

2025-11-11 11:22:03 +00:00
# Stage 1: Install dependencies
2025-11-11 10:24:43 +00:00
FROM python:3.11-slim AS builder
2025-11-05 16:48:41 +00:00
WORKDIR /app
2025-11-11 11:22:03 +00:00
# Install Python packages
2025-11-05 16:48:41 +00:00
COPY requirements.txt .
2025-11-11 11:22:03 +00:00
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir --prefix=/install -r requirements.txt && \
# Clean up unnecessary files to reduce image size
find /install -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true && \
find /install -type f -name "*.pyc" -delete && \
find /install -type d -name "tests" -exec rm -rf {} + 2>/dev/null || true && \
find /install -type d -name "*.dist-info" -exec rm -rf {}/RECORD {} + 2>/dev/null || true
# Stage 2: Final minimal image
2025-11-11 10:24:43 +00:00
FROM python:3.11-slim
WORKDIR /app
2025-11-11 11:22:03 +00:00
# Copy only installed packages (no pip cache, no build artifacts)
COPY --from=builder /install /usr/local
2025-11-05 16:48:41 +00:00
# Copy application files
COPY backend ./backend
COPY frontend ./frontend
COPY config.yaml .
COPY plugins ./plugins
COPY themes ./themes
2025-11-14 19:33:36 +00:00
COPY generate_password.py .
2025-11-05 16:48:41 +00:00
# Create data directory
RUN mkdir -p data
2025-11-05 16:48:41 +00:00
# Expose port
EXPOSE 8000
# Health check
2025-11-11 11:22:03 +00:00
HEALTHCHECK --interval=60s --timeout=3s --start-period=5s --retries=3 \
2025-11-05 16:48:41 +00:00
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')"
# Run the application
CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "8000"]