From 54fe139a4677bd95450cf2d61a77049ce4f81da6 Mon Sep 17 00:00:00 2001 From: Mogeko Date: Thu, 18 Nov 2021 00:14:34 +0000 Subject: [PATCH] build: set up Makefile --- .devcontainer/Dockerfile | 4 ++-- .gitignore | 3 +++ Makefile | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 Makefile diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index d8239fe..60584df 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -37,5 +37,5 @@ ENTRYPOINT [ "/usr/local/share/docker-init.sh" ] CMD [ "sleep", "infinity" ] # [Optional] Uncomment this section to install additional OS packages. -# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ -# && apt-get -y install --no-install-recommends \ No newline at end of file +RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ + && apt-get -y install --no-install-recommends make \ No newline at end of file diff --git a/.gitignore b/.gitignore index 830f56e..7a9ac5f 100644 --- a/.gitignore +++ b/.gitignore @@ -73,3 +73,6 @@ $RECYCLE.BIN/ *.lnk # End of https://www.toptal.com/developers/gitignore/api/macos,windows,linux + +# Custom dir for test +tests/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..33c15a3 --- /dev/null +++ b/Makefile @@ -0,0 +1,34 @@ +CMD = /usr/bin/docker +IMAGE = mogeko/qbittorrent +VERSION = 4.3.8 +PORT = 8080 +CONF_DIR = $(shell pwd)/tests/config +DL_DIR = $(shell pwd)/tests/data + +.PHONY: all build run help + +all: build run + +build: + @$(CMD) build . \ + --build-arg VERSION=$(VERSION) \ + --tag $(IMAGE) + +run: id := $(shell head -200 /dev/urandom | cksum | cut -f1 -d " ") +run: + @-$(CMD) run -it \ + --name qbt-$(id) \ + -p 6881:6881 \ + -p 6881:6881/udp \ + -p $(PORT):8080 \ + -v $(CONF_DIR):/config \ + -v $(DL_DIR):/downloads \ + $(IMAGE) + @$(CMD) rm -f qbt-$(id) + +help: id := $(shell head -200 /dev/urandom | cksum | cut -f1 -d " ") +help: + @-$(CMD) run -it --name qbt-$(id) $(IMAGE) --help + @$(CMD) rm -f qbt-$(id) + +rm: clean