Skip to content

Commit 4b630c9

Browse files
authored
Merge pull request #132 from ZZiigguurraatt/add_docker_make_targets
make: add docker image targets
2 parents bb991a5 + b33fc33 commit 4b630c9

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

Makefile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ CP := cp
1818
MAKE := make
1919
DOCKER_TOOLS = docker run -v $$(pwd):/build lndmon-tools
2020

21+
DOCKER_IMAGE := lndmon
22+
# Derive the tag from the current commit, appending "-dirty" if the working
23+
# tree has uncommitted changes. --match='__no_such_tag__' forces git to ignore
24+
# all tags and fall back to the short commit hash via --always.
25+
DOCKER_COMMIT := $(shell git describe --always --dirty --match='__no_such_tag__')
26+
DOCKER_TAG := $(DOCKER_COMMIT)
27+
2128
LINT = $(LINT_BIN) run -v
2229

2330
default: build
@@ -43,6 +50,16 @@ build:
4350
# =========
4451
# UTILITIES
4552
# =========
53+
docker-build:
54+
@$(call print, "Building lndmon docker image.")
55+
docker build -t $(DOCKER_IMAGE):$(DOCKER_TAG) .
56+
57+
docker-push:
58+
@$(call print, "Pushing lndmon docker image.")
59+
docker push $(DOCKER_IMAGE):$(DOCKER_TAG)
60+
61+
docker-build-push: docker-build docker-push
62+
4663
docker-tools:
4764
@$(call print, "Building tools docker image.")
4865
docker build -q -t lndmon-tools $(TOOLS_DIR)

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,24 @@ cd lndmon/cmd/lndmon
134134
go build
135135
```
136136

137+
### Makefile commands
138+
139+
The repository ships with a `Makefile` that wraps the most common development
140+
tasks. Run `make list` to print all available targets, or use one of the
141+
commands below:
142+
143+
| Command | Description |
144+
| --- | --- |
145+
| `make build` | Build the `lndmon` binary. |
146+
| `make docker-build` | Build the `lndmon` Docker image. The tag is derived from the current commit (e.g. `lndmon:<commit>`), 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`. |
147+
| `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). |
148+
| `make docker-build-push` | Build and then push the `lndmon` Docker image in one step. |
149+
| `make docker-tools` | Build the `lndmon-tools` Docker image used for linting. |
150+
| `make fmt` | Fix imports and format the source. |
151+
| `make lint` | Run the linters (uses the tools Docker image). |
152+
| `make clean` | Remove the built `lndmon` binary. |
153+
| `make list` | List all available `make` targets. |
154+
137155
## Options
138156

139157
```

0 commit comments

Comments
 (0)