diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 83f4fb2..f6611c8 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -30,6 +30,8 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + with: + platforms: linux/amd64,linux/arm64 - name: Log in to Container Registry if: github.event_name != 'pull_request' @@ -63,3 +65,5 @@ jobs: cache-from: type=gha cache-to: type=gha,mode=max platforms: linux/amd64,linux/arm64 + # Build for both amd64 and arm64 architectures + # This enables the image to run on both x86_64 and ARM devices (Raspberry Pi, Orange Pi, etc.) \ No newline at end of file diff --git a/DOCKER.md b/DOCKER.md index 8eec26a..f73f95d 100644 --- a/DOCKER.md +++ b/DOCKER.md @@ -322,22 +322,28 @@ Try these solutions: sudo modprobe veth ``` -3. **Use host network mode for build** (temporary workaround): +3. **Build directly with docker build** (bypasses compose networking - RECOMMENDED): ```bash - DOCKER_BUILDKIT=0 docker compose build --network=host + # Build the image directly + DOCKER_BUILDKIT=0 docker build -t meshcore-bot:latest . + + # Then use docker compose normally (it will use the existing image) + docker compose up -d + ``` + This bypasses Docker Compose's networking setup during build, which often fails on ARM devices. + +4. **Use host network mode for build** (alternative): + ```bash + DOCKER_BUILDKIT=0 docker build --network=host -t meshcore-bot:latest . + docker compose up -d ``` -4. **Check Docker bridge configuration**: +5. **Check Docker bridge configuration**: ```bash sudo brctl show ``` If bridge doesn't exist, Docker may need to be reconfigured. -5. **Try building without BuildKit**: - ```bash - DOCKER_BUILDKIT=0 docker compose build - ``` - 6. **Check Docker daemon logs**: ```bash sudo journalctl -u docker -n 50 diff --git a/Dockerfile b/Dockerfile index d523ffc..b8e14bb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,10 @@ # 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 \ +# Install build dependencies (with cache mount for apt) +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + apt-get update && apt-get install -y --no-install-recommends \ build-essential \ && rm -rf /var/lib/apt/lists/* @@ -12,14 +14,17 @@ WORKDIR /build # Copy dependency files COPY requirements.txt pyproject.toml ./ -# Install Python dependencies -RUN pip install --no-cache-dir --user -r requirements.txt +# Install Python dependencies (with cache mount for pip) +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install --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 \ +# Install runtime dependencies (with cache mount for apt) +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + apt-get update && apt-get install -y --no-install-recommends \ # For serial port access udev \ # For BLE support (optional, but commonly needed)