-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
114 lines (98 loc) · 3.99 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
VERSION="1.6.5"
default: debug test run
debug: version template dockerfile
go vet ./...
gofmt -d ./
gofmt -w ./
go build -mod vendor -o ./fave
test:
go test ./...
run:
@./fave -host 0.0.0.0 -port 8080 -dir ./hosts -debug true -keepalive true --color=always
build: clean version template dockerfile
@-mkdir ./bin
@cd ./bin
@cd ..
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -mod vendor -a -o ./bin/fave.linux-amd64 -ldflags='-X main.Version=$(VERSION) -extldflags "-static"'
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -mod vendor -a -o ./bin/fave.darwin-amd64 -ldflags='-X main.Version=$(VERSION) -extldflags "-static"'
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -mod vendor -a -o ./bin/fave.windows-amd64.exe -ldflags='-X main.Version=$(VERSION) -extldflags "-static"'
cd ./bin && find . -name 'fave*' | xargs -I{} tar czf {}.tar.gz {}
@-rm ./bin/fave.linux-amd64
@-rm ./bin/fave.darwin-amd64
@-rm ./bin/fave.windows-amd64.exe
@cp -R ./hosts/localhost ./bin/localhost
@-find ./bin/localhost -type f -name '.*' -exec rm -f {} \;
@-rm -R ./bin/localhost/htdocs/products
@-rm -R ./bin/localhost/htdocs/public
@-rm ./bin/localhost/config/*
@-rm ./bin/localhost/htdocs/*
@-rm ./bin/localhost/logs/*
@-rm ./bin/localhost/tmp/*
cd ./bin && tar -zcf localhost.tar.gz ./localhost
@-rm -r ./bin/localhost
cp ./Dockerfile ./bin/Dockerfile
cd ./bin && shasum -a 256 * > sha256sum.txt
cat ./bin/sha256sum.txt
clean:
@-rm -r ./bin
format:
gofmt -w ./
update:
go mod vendor
go mod download
version:
@echo "package consts" > engine/consts/consts_version.go
@echo "" >> engine/consts/consts_version.go
@echo "const ServerVersion = \"${VERSION}\"" >> engine/consts/consts_version.go
template:
@./support/template.sh
@gofmt -w ./engine/assets/template/
dockerfile:
@echo "FROM debian:latest" > Dockerfile
@echo "MAINTAINER Vova Tkach <[email protected]>" >> Dockerfile
@echo "" >> Dockerfile
@echo "ENV FAVE_HOST=0.0.0.0 FAVE_PORT=8080 FAVE_DIR=/app/hosts FAVE_DEBUG=false FAVE_KEEPALIVE=true" >> Dockerfile
@echo "" >> Dockerfile
@echo "ADD https://github.com/vladimirok5959/golang-fave/releases/download/v${VERSION}/fave.linux-amd64.tar.gz /app/fave.linux-amd64.tar.gz" >> Dockerfile
@echo "ADD https://github.com/vladimirok5959/golang-fave/releases/download/v${VERSION}/localhost.tar.gz /app/hosts/localhost.tar.gz" >> Dockerfile
@echo "" >> Dockerfile
@echo "ARG DEBIAN_FRONTEND=noninteractive" >> Dockerfile
@echo "" >> Dockerfile
@echo "RUN apt-get -y update && apt-get -y upgrade && \\" >> Dockerfile
@echo " apt-get install -y ca-certificates && \\" >> Dockerfile
@echo " dpkg-reconfigure -p critical ca-certificates && \\" >> Dockerfile
@echo " tar -zxf /app/fave.linux-amd64.tar.gz -C /app && \\" >> Dockerfile
@echo " tar -zxf /app/hosts/localhost.tar.gz -C /app/hosts && \\" >> Dockerfile
@echo " rm /app/fave.linux-amd64.tar.gz && \\" >> Dockerfile
@echo " rm /app/hosts/localhost.tar.gz && \\" >> Dockerfile
@echo " mkdir /app/src && cp -R /app/hosts/localhost /app/src && \\" >> Dockerfile
@echo " chmod +x /app/fave.linux-amd64" >> Dockerfile
@echo "" >> Dockerfile
@echo "EXPOSE 8080" >> Dockerfile
@echo "VOLUME /app/hosts" >> Dockerfile
@echo "" >> Dockerfile
@echo "CMD /app/fave.linux-amd64" >> Dockerfile
docker-test: dockerfile
@-docker stop fave-test
@-docker rm fave-test
@-docker rmi fave
docker build --rm=false --force-rm=true -t fave:latest .
docker run --rm --name fave-test --cpus=".2" -m 200m -p 8080:8080 -t -i fave:latest /app/fave.linux-amd64
@-docker rmi fave:latest
docker-img: dockerfile
docker build -t fave:latest .
docker-push: docker-img
docker tag fave:latest vladimirok5959/fave:${VERSION}
docker tag fave:latest vladimirok5959/fave:latest
docker login
docker push vladimirok5959/fave:${VERSION}
docker push vladimirok5959/fave:latest
docker rmi vladimirok5959/fave:${VERSION}
docker rmi vladimirok5959/fave:latest
docker rmi fave:latest
docker-clr:
@-docker stop fave-test
@-docker rm fave-test
@-docker rmi fave
migrate:
./support/migrate.sh