-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
53 lines (42 loc) · 1.51 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
.PHONY: help build start printos
timestamp := $(shell date +'%Y_%m_%d_%H_%M_%S')
help: ## : Show this help
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z0-9_%-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' ${MAKEFILE_LIST}
build: ## : Build dependencies
go mod tidy
GOOS=darwin GOARCH=amd64 go build -o build/strings main.go
start: build ## : Start the client
DB_USER=postgres \
DB_PASS= \
DB_NAME=strings \
DB_HOST=localhost \
DB_PORT=5432 \
./build/strings
run: ## : Run app without build
DB_USER=postgres \
DB_PASS= \
DB_NAME=strings \
DB_HOST=localhost \
DB_PORT=5432 \
./build/strings
dump: ## : dump postgres database
/usr/local/bin/pg_dump --dbname=strings --file="${HOME}/strings_localhost-$(timestamp)-dump.sql" --username=postgres --host=localhost --port=5432
docker: ## : Make docker image
rm -f build/strings-docker
go mod tidy
# https://stackoverflow.com/questions/34729748/installed-go-binary-not-found-in-path-on-alpine-linux-docker
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 GO111MODULE=on go build -o build/strings-linux-amd64 main.go
docker build -t psytek/strings:local .
docker-run: ## : Run docker image
docker run -it \
-p 8081:8080 \
-e DB_HOST=host.docker.internal \
-e DB_PORT=5432 \
-e DB_NAME=strings \
-e DB_USER=postgres \
-e DB_PASS=password \
psytek/strings:local
docker-exec: ## : Run docker image in exec mode for debug
docker run -it psytek/strings:local sh
docker-push: docker ## : Push docker image to docker hub
docker push psytek/strings:local