From 051818e964fab8851c5af4914f3cdf8d20010e8e Mon Sep 17 00:00:00 2001 From: Serge Bazanski Date: Sun, 29 Nov 2020 20:44:03 +0100 Subject: [PATCH] EXAMPLE: makefile instead of taskfile Do not merge. This is an example for @thinkofher. --- .gitignore | 4 ++++ Dockerfile | 18 +++------------- Makefile | 35 ++++++++++++++++++++++++++++++ README.md | 8 +++---- Taskfile.yml | 60 ---------------------------------------------------- 5 files changed, 45 insertions(+), 80 deletions(-) create mode 100644 Makefile delete mode 100644 Taskfile.yml diff --git a/.gitignore b/.gitignore index 59c4f0b..17898f4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # Binaries for programs and plugins long-season long-season-cli +embedfiles *.exe *.exe~ *.dll @@ -21,3 +22,6 @@ long-season.db # embedded go file pkg/static/files.gen.go + +# vim crap +**swp diff --git a/Dockerfile b/Dockerfile index d9e241d..55bf595 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,11 +2,7 @@ FROM golang:1.15-alpine WORKDIR $GOPATH/bin -RUN apk add --no-cache git \ - && export GO111MODULE=off \ - && go get 4d63.com/embedfiles \ - && export GO111MODULE=on - +RUN apk add --no-cache git make WORKDIR /opt/db ENV LS_BOLT_DB /opt/db/bolt.db @@ -15,15 +11,7 @@ ENV SRC /go/src/app WORKDIR $SRC COPY . . -RUN go get -d -v ./... -RUN embedfiles -out=pkg/static/files.gen.go -pkg=static web - - -RUN go build -o "long-season" ./cmd/server/main.go \ - && mv "long-season" $GOPATH/bin/ - -RUN go build -o "long-season-cli" ./cmd/cli/main.go \ - && mv "long-season-cli" $GOPATH/bin/ +RUN make build SERVER=$GOPATH/bin/long-season CLI=$GOPATH/bin/long-season-cli WORKDIR / -RUN rm -rf $SRC $GOPATH/bin/embedfiles +RUN rm -rf $SRC diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..90b3d47 --- /dev/null +++ b/Makefile @@ -0,0 +1,35 @@ +SERVER := long-season +CLI := long-season-cli +EMBEDFILES := $(CURDIR)/embedfiles +STATIC := pkg/static/files.gen.go + +default: build + +$(SERVER): $(STATIC) $(wildcard cmd/server/** pkg/**) + go build -o $@ cmd/server/main.go + +$(CLI): $(SERVER) $(wildcard cmd/cli/** pkg/**) + go build -o $@ cmd/cli/main.go + +$(EMBEDFILES): + GO111MODULE=off go get 4d63.com/embedfiles + GO111MODULE=off go build -o $@ 4d63.com/embedfiles + +$(STATIC): $(EMBEDFILES) $(wildcard web/**) + $(EMBEDFILES) -out=$@ -pkg=static web + +.PHONY: default build run clean lint test + +build: $(SERVER) $(CLI) + +run: $(SERVER) + $(SERVER) + +clean: + rm -f $(SERVER) $(CLI) $(EMBEDFILES) $(STATIC) + +lint: + golint ./... + +test: $(STATIC) + go test ./... diff --git a/README.md b/README.md index 2610bad..7127d25 100644 --- a/README.md +++ b/README.md @@ -17,15 +17,13 @@ Basically: users are adding MAC addresses of their devices to their profile and ## Installing -Right now you have to build `long-season` manually. But you can facilitate your work by using a [task](https://taskfile.dev). +Right now you have to build `long-season` manually. But you can facilitate your work by using our Makefile. Clone this repository and enter below command in your shell (or whatever you are using): - $ task + $ make -Now you have `long-season` and `long-season-cli` in your root directory. You can use `task` for running project and rebuilding it whenever some changes occurs. - - $ task --watch run +Now you have `long-season` and `long-season-cli` in your root directory. You can also build docker image or just use `docker-compose`, which is the simplest way to start development or use `long-season`. diff --git a/Taskfile.yml b/Taskfile.yml deleted file mode 100644 index 12c5302..0000000 --- a/Taskfile.yml +++ /dev/null @@ -1,60 +0,0 @@ -# https://taskfile.dev - ---- -version: '2' - -vars: - NAME: long-season - NAME_CLI: long-season-cli - -tasks: - default: - deps: [server, cli] - - tools: - cmds: - - env GO111MODULE=off go get 4d63.com/embedfiles - - server: - deps: [gen] - cmds: - - go build -o {{ .NAME }} cmd/server/main.go - sources: - - ./**/*.go - - ./**/*.html - generates: - - ./{{ .NAME }} - - cli: - cmds: - - go build -o {{ .NAME_CLI }} cmd/cli/main.go - - run: - deps: [server] - cmds: - - ./{{ .NAME }} - - gen: - deps: [tools] - cmds: - - embedfiles -out=pkg/static/files.gen.go -pkg=static web - sources: - - ./**/*.html - - ./**/*.css - - ./**/*.js - generates: - - ./pkg/static/files.gen.go - - clean: - cmds: - - rm -f ./{{ .NAME }} ./{{ .NAME_CLI }} - - rm -f ./pkg/static/files.gen.go - - lint: - cmds: - - golint ./... - - test: - deps: [gen] - cmds: - - go test ./...