From 58043c6a76d22599de1a8f6239c9f0d13aee9ca8 Mon Sep 17 00:00:00 2001 From: Guillermo Villar Date: Tue, 11 Nov 2025 11:41:20 +0100 Subject: [PATCH 1/3] removed stuff --- Dockerfile | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index e770b54d..10889b7c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,12 +23,8 @@ FROM python:3.11-slim WORKDIR /app -# Install only runtime dependencies (not build tools!) -RUN apt-get update && apt-get install -y --no-install-recommends \ - libssl3 \ - && rm -rf /var/lib/apt/lists/* - # Copy installed Python packages from builder +# (python:3.11-slim already has all needed runtime libraries) COPY --from=builder /install /usr/local # Copy application files From cefb9057c1410e9ed8cc735b3c845e6f58fbbaea Mon Sep 17 00:00:00 2001 From: Guillermo Villar Date: Tue, 11 Nov 2025 12:06:00 +0100 Subject: [PATCH 2/3] remove multi-arch for now --- .github/workflows/docker-publish.yml | 2 +- Dockerfile | 30 +++++++++++----------------- README.md | 2 -- 3 files changed, 13 insertions(+), 21 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 4b6e7aca..249144d0 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -58,7 +58,7 @@ jobs: uses: docker/build-push-action@v5 with: context: . - platforms: linux/amd64,linux/arm64,linux/arm/v7 + platforms: linux/amd64 #,linux/arm64,linux/arm/v7 push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile index 10889b7c..157fdabe 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,31 +1,25 @@ -# Build stage - compile dependencies +# Build stage - install dependencies FROM python:3.11-slim AS builder WORKDIR /app -# Install build dependencies (only in this stage) -RUN apt-get update && apt-get install -y --no-install-recommends \ - gcc \ - libssl-dev \ - libffi-dev \ - python3-dev \ - cargo \ - rustc \ - && rm -rf /var/lib/apt/lists/* - -# Install Python dependencies +# Install Python dependencies to a virtual environment +# (Most packages have pre-built wheels for amd64, no compilation needed!) COPY requirements.txt . -RUN pip install --no-cache-dir --upgrade pip && \ - pip install --no-cache-dir --prefix=/install -r requirements.txt +RUN python -m venv /opt/venv && \ + /opt/venv/bin/pip install --no-cache-dir --upgrade pip && \ + /opt/venv/bin/pip install --no-cache-dir -r requirements.txt -# Final stage - minimal runtime image +# Final stage - minimal runtime image (no build tools!) FROM python:3.11-slim WORKDIR /app -# Copy installed Python packages from builder -# (python:3.11-slim already has all needed runtime libraries) -COPY --from=builder /install /usr/local +# Copy only the virtual environment from builder (no bloat!) +COPY --from=builder /opt/venv /opt/venv + +# Use the virtual environment +ENV PATH="/opt/venv/bin:$PATH" # Copy application files COPY backend ./backend diff --git a/README.md b/README.md index 7d406b11..07fb4b07 100644 --- a/README.md +++ b/README.md @@ -46,8 +46,6 @@ NoteDiscovery is a **lightweight, self-hosted note-taking application** that put Use the pre-built image directly from GHCR - no building required! > **💡 Tip**: Always use `ghcr.io/gamosoft/notediscovery:latest` to get the newest features and fixes. Images are automatically built when PRs are merged to main. -> -> **🖥️ Multi-Architecture Support**: Images are built for `x86_64`, `ARM64` (Raspberry Pi 3/4/5), and `ARM v7` (older Raspberry Pi models). Docker will automatically pull the correct version for your device. > **📁 Important - Volume Mapping**: The container needs local folders/files to work: > - **Required**: `data` folder (your notes will be stored here) From c5694c21a82cca0302431c033591a9078764bbbf Mon Sep 17 00:00:00 2001 From: Guillermo Villar Date: Tue, 11 Nov 2025 12:22:03 +0100 Subject: [PATCH 3/3] reduced image size --- Dockerfile | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Dockerfile b/Dockerfile index 157fdabe..199efe89 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,25 +1,25 @@ -# Build stage - install dependencies +# Stage 1: Install dependencies FROM python:3.11-slim AS builder WORKDIR /app -# Install Python dependencies to a virtual environment -# (Most packages have pre-built wheels for amd64, no compilation needed!) +# Install Python packages COPY requirements.txt . -RUN python -m venv /opt/venv && \ - /opt/venv/bin/pip install --no-cache-dir --upgrade pip && \ - /opt/venv/bin/pip install --no-cache-dir -r requirements.txt - -# Final stage - minimal runtime image (no build tools!) +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 FROM python:3.11-slim WORKDIR /app -# Copy only the virtual environment from builder (no bloat!) -COPY --from=builder /opt/venv /opt/venv - -# Use the virtual environment -ENV PATH="/opt/venv/bin:$PATH" +# Copy only installed packages (no pip cache, no build artifacts) +COPY --from=builder /install /usr/local # Copy application files COPY backend ./backend @@ -35,7 +35,7 @@ RUN mkdir -p data/notes data/search_index EXPOSE 8000 # Health check -HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ +HEALTHCHECK --interval=60s --timeout=3s --start-period=5s --retries=3 \ CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')" # Run the application