diff --git a/Makefile b/Makefile index 895391d..82bbbf0 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,19 @@ -.PHONY: install run develop clean build build-appimage build-exe dist sync-version wheel node_modules python +.PHONY: install run develop clean build build-appimage build-exe dist sync-version wheel node_modules python build-docker run-docker PYTHON ?= python POETRY = $(PYTHON) -m poetry NPM = npm +DOCKER_COMPOSE_CMD ?= docker compose +DOCKER_COMPOSE_FILE ?= docker-compose.yml +DOCKER_IMAGE ?= reticulum-meshchatx:local +DOCKER_BUILDER ?= meshchatx-builder +DOCKER_PLATFORMS ?= linux/amd64 +DOCKER_BUILD_FLAGS ?= --load +DOCKER_BUILD_ARGS ?= +DOCKER_CONTEXT ?= . +DOCKERFILE ?= Dockerfile + install: sync-version node_modules python node_modules: @@ -43,3 +53,20 @@ clean: sync-version: $(PYTHON) scripts/sync_version.py + +build-docker: + @if ! docker buildx inspect $(DOCKER_BUILDER) >/dev/null 2>&1; then \ + docker buildx create --name $(DOCKER_BUILDER) --use >/dev/null; \ + else \ + docker buildx use $(DOCKER_BUILDER); \ + fi + docker buildx build --builder $(DOCKER_BUILDER) --platform $(DOCKER_PLATFORMS) \ + $(DOCKER_BUILD_FLAGS) \ + -t $(DOCKER_IMAGE) \ + $(DOCKER_BUILD_ARGS) \ + -f $(DOCKERFILE) \ + $(DOCKER_CONTEXT) + +run-docker: + MESHCHAT_IMAGE="$(DOCKER_IMAGE)" \ + $(DOCKER_COMPOSE_CMD) -f $(DOCKER_COMPOSE_FILE) up --remove-orphans --pull never reticulum-meshchatx diff --git a/README.md b/README.md index 40946af..b1ee9bb 100644 --- a/README.md +++ b/README.md @@ -55,9 +55,19 @@ The wheel includes the frontend `public/` assets, `logo/`, and the CLI entry poi ### Building in Docker ```bash -make docker-build +make build-docker ``` +`build-docker` creates `reticulum-meshchatx:local` (or `$(DOCKER_IMAGE)` if you override it) via `docker buildx`. Set `DOCKER_PLATFORMS` to `linux/amd64,linux/arm64` when you need multi-arch images, and adjust `DOCKER_BUILD_FLAGS`/`DOCKER_BUILD_ARGS` to control `--load`/`--push`. + +### Running with Docker Compose + +```bash +make run-docker +``` + +`run-docker` feeds the locally-built image into `docker compose -f docker-compose.yml up --remove-orphans --pull never reticulum-meshchatx`. The compose file uses the `MESHCHAT_IMAGE` env var so you can override the target image without editing the YAML (the default still points at `ghcr.io/sudo-ivan/reticulum-meshchatx:latest`). Use `docker compose down` or `Ctrl+C` to stop the container. + The Electron build artifacts will still live under `dist/` for releases. ## Python packaging diff --git a/docker-compose.yml b/docker-compose.yml index 1555e54..d513770 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ services: reticulum-meshchatx: container_name: reticulum-meshchatx - image: ghcr.io/sudo-ivan/reticulum-meshchatx:latest + image: ${MESHCHAT_IMAGE:-ghcr.io/sudo-ivan/reticulum-meshchatx:latest} pull_policy: always restart: unless-stopped # Make the meshchat web interface accessible from the host on port 8000