diff --git a/Makefile b/Makefile index 4e64040..c3d6da5 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,13 @@ CP := cp MAKE := make DOCKER_TOOLS = docker run -v $$(pwd):/build lndmon-tools +DOCKER_IMAGE := lndmon +# Derive the tag from the current commit, appending "-dirty" if the working +# tree has uncommitted changes. --match='__no_such_tag__' forces git to ignore +# all tags and fall back to the short commit hash via --always. +DOCKER_COMMIT := $(shell git describe --always --dirty --match='__no_such_tag__') +DOCKER_TAG := $(DOCKER_COMMIT) + LINT = $(LINT_BIN) run -v default: build @@ -43,6 +50,16 @@ build: # ========= # UTILITIES # ========= +docker-build: + @$(call print, "Building lndmon docker image.") + docker build -t $(DOCKER_IMAGE):$(DOCKER_TAG) . + +docker-push: + @$(call print, "Pushing lndmon docker image.") + docker push $(DOCKER_IMAGE):$(DOCKER_TAG) + +docker-build-push: docker-build docker-push + docker-tools: @$(call print, "Building tools docker image.") docker build -q -t lndmon-tools $(TOOLS_DIR) diff --git a/README.md b/README.md index 301f965..778cb2c 100644 --- a/README.md +++ b/README.md @@ -134,6 +134,24 @@ cd lndmon/cmd/lndmon go build ``` +### Makefile commands + +The repository ships with a `Makefile` that wraps the most common development +tasks. Run `make list` to print all available targets, or use one of the +commands below: + +| Command | Description | +| --- | --- | +| `make build` | Build the `lndmon` binary. | +| `make docker-build` | Build the `lndmon` Docker image. The tag is derived from the current commit (e.g. `lndmon:`), with a `-dirty` suffix when the working tree has uncommitted changes. Override with `DOCKER_IMAGE`/`DOCKER_TAG`, e.g. `make docker-build DOCKER_TAG=latest`. | +| `make docker-push` | Push the `lndmon` Docker image (uses the same `DOCKER_IMAGE`/`DOCKER_TAG` as `docker-build`; set `DOCKER_IMAGE` to a registry path to push elsewhere). | +| `make docker-build-push` | Build and then push the `lndmon` Docker image in one step. | +| `make docker-tools` | Build the `lndmon-tools` Docker image used for linting. | +| `make fmt` | Fix imports and format the source. | +| `make lint` | Run the linters (uses the tools Docker image). | +| `make clean` | Remove the built `lndmon` binary. | +| `make list` | List all available `make` targets. | + ## Options ```