docker-net-dhcp/Makefile

56 lines
1.4 KiB
Makefile
Raw Normal View History

2021-06-07 20:30:20 +00:00
PLUGIN_NAME = ghcr.io/devplayer0/docker-net-dhcp
2020-05-18 16:39:32 +00:00
PLUGIN_TAG ?= golang
2021-06-10 17:11:25 +00:00
PLATFORMS ?= linux/amd64,linux/arm64
2019-08-22 14:34:10 +00:00
SOURCES = $(shell find pkg/ cmd/ -name '*.go')
2020-05-18 16:39:32 +00:00
BINARY = bin/net-dhcp
.PHONY: all debug build create enable disable pdebug push clean
2020-05-18 16:39:32 +00:00
all: create enable
bin/%: $(SOURCES)
go build -o $@ ./cmd/$(shell basename $@)
2020-05-18 16:39:32 +00:00
debug: $(BINARY)
sudo $< -log debug
build: $(SOURCES)
docker build -t $(PLUGIN_NAME):rootfs .
plugin/rootfs: build
mkdir -p plugin/rootfs
docker create --name tmp $(PLUGIN_NAME):rootfs
docker export tmp | tar xC plugin/rootfs
docker rm -vf tmp
plugin: plugin/rootfs config.json
2020-05-18 16:39:32 +00:00
cp config.json $@/
create: plugin
docker plugin rm -f $(PLUGIN_NAME):$(PLUGIN_TAG) || true
docker plugin create $(PLUGIN_NAME):$(PLUGIN_TAG) $<
2021-06-07 19:55:45 +00:00
docker plugin set $(PLUGIN_NAME):$(PLUGIN_TAG) LOG_LEVEL=trace
2020-05-18 16:39:32 +00:00
enable: plugin
docker plugin enable $(PLUGIN_NAME):$(PLUGIN_TAG)
2020-05-18 16:39:32 +00:00
disable:
docker plugin disable $(PLUGIN_NAME):$(PLUGIN_TAG)
2020-05-18 16:39:32 +00:00
pdebug: create enable
sudo sh -c 'tail -f /var/lib/docker/plugins/*/rootfs/var/log/net-dhcp.log'
2020-05-18 16:39:32 +00:00
2021-06-07 20:30:20 +00:00
push: create
docker plugin push $(PLUGIN_NAME):$(PLUGIN_TAG)
2019-08-22 14:34:10 +00:00
2021-06-10 17:11:25 +00:00
multiarch: $(SOURCES)
docker buildx build --platform=$(PLATFORMS) -o type=local,dest=$@ .
push-multiarch: multiarch config.json
scripts/push_multiarch_plugin.py -p $(PLATFORMS) config.json multiarch $(PLUGIN_NAME):$(PLUGIN_TAG)
2019-08-22 14:34:10 +00:00
clean:
2021-06-10 17:11:25 +00:00
-rm -rf multiarch/
-rm -rf plugin/
-rm bin/*