Makefile 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. VERSION="1.3.6"
  2. default: debug test run
  3. debug: version template dockerfile
  4. go vet ./...
  5. gofmt -d ./
  6. gofmt -w ./
  7. go build -mod vendor -o ./fave
  8. test:
  9. go test ./...
  10. run:
  11. @./fave -host 0.0.0.0 -port 8080 -dir ./hosts -debug true -keepalive true
  12. build: clean version template dockerfile
  13. @-mkdir ./bin
  14. @cd ./bin
  15. @cd ..
  16. CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -mod vendor -a -o ./bin/fave.linux-amd64 -ldflags='-X main.Version=$(VERSION) -extldflags "-static"'
  17. CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -mod vendor -a -o ./bin/fave.darwin-amd64 -ldflags='-X main.Version=$(VERSION) -extldflags "-static"'
  18. 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"'
  19. cd ./bin && find . -name 'fave*' | xargs -I{} tar czf {}.tar.gz {}
  20. @cp -R ./hosts/localhost ./bin/localhost
  21. @-find ./bin/localhost -type f -name '.*' -exec rm -f {} \;
  22. @-find ./bin/localhost -type f -name '*.json' -exec rm -f {} \;
  23. @-rm ./bin/localhost/tmp/*
  24. cd ./bin && tar -zcf localhost.tar.gz ./localhost
  25. @-rm -r ./bin/localhost
  26. cp ./Dockerfile ./bin/Dockerfile
  27. cd ./bin && shasum -a 256 * > sha256sum.txt
  28. cat ./bin/sha256sum.txt
  29. clean:
  30. @-rm -r ./bin
  31. format:
  32. gofmt -w ./
  33. update:
  34. go mod vendor
  35. go mod download
  36. version:
  37. @echo "package consts" > consts/consts_version.go
  38. @echo "" >> consts/consts_version.go
  39. @echo "const ServerVersion = \"${VERSION}\"" >> consts/consts_version.go
  40. template:
  41. @./support/template.sh
  42. @gofmt -w ./assets/template/
  43. dockerfile:
  44. @echo "FROM debian:latest" > Dockerfile
  45. @echo "MAINTAINER Vova Tkach <vladimirok5959@gmail.com>" >> Dockerfile
  46. @echo "" >> Dockerfile
  47. @echo "ENV FAVE_HOST=0.0.0.0 FAVE_PORT=8080 FAVE_DIR=/app/hosts FAVE_DEBUG=false FAVE_KEEPALIVE=true" >> Dockerfile
  48. @echo "" >> Dockerfile
  49. @echo "ADD https://github.com/vladimirok5959/golang-fave/releases/download/v${VERSION}/fave.linux-amd64.tar.gz /app/fave.linux-amd64.tar.gz" >> Dockerfile
  50. @echo "ADD https://github.com/vladimirok5959/golang-fave/releases/download/v${VERSION}/localhost.tar.gz /app/hosts/localhost.tar.gz" >> Dockerfile
  51. @echo "" >> Dockerfile
  52. @echo "RUN tar -zxf /app/fave.linux-amd64.tar.gz -C /app && \\" >> Dockerfile
  53. @echo " tar -zxf /app/hosts/localhost.tar.gz -C /app/hosts && \\" >> Dockerfile
  54. @echo " rm /app/fave.linux-amd64.tar.gz && \\" >> Dockerfile
  55. @echo " rm /app/hosts/localhost.tar.gz && \\" >> Dockerfile
  56. @echo " mkdir /app/src && cp -R /app/hosts/localhost /app/src && \\" >> Dockerfile
  57. @echo " chmod +x /app/fave.linux-amd64" >> Dockerfile
  58. @echo "" >> Dockerfile
  59. @echo "EXPOSE 8080" >> Dockerfile
  60. @echo "VOLUME /app/hosts" >> Dockerfile
  61. @echo "" >> Dockerfile
  62. @echo "CMD /app/fave.linux-amd64" >> Dockerfile
  63. docker-test: dockerfile
  64. @-docker stop fave-test
  65. @-docker rm fave-test
  66. @-docker rmi fave
  67. docker build --rm=false --force-rm=true -t fave:latest .
  68. docker run -d --name fave-test --cpus=".2" -m 200m -p 8080:8080 -t -i fave:latest /app/fave.linux-amd64
  69. docker-img: dockerfile
  70. docker build -t fave:latest .
  71. docker-push: docker-img
  72. docker tag fave:latest vladimirok5959/fave:${VERSION}
  73. docker tag fave:latest vladimirok5959/fave:latest
  74. docker login
  75. docker push vladimirok5959/fave:${VERSION}
  76. docker push vladimirok5959/fave:latest
  77. docker rmi vladimirok5959/fave:${VERSION}
  78. docker rmi vladimirok5959/fave:latest
  79. docker rmi fave:latest
  80. docker-clr:
  81. @-docker stop fave-test
  82. @-docker rm fave-test
  83. @-docker rmi fave
  84. migrate:
  85. ./support/migrate.sh
  86. cy-dev:
  87. yarn cypress open
  88. cy:
  89. yarn cypress run
  90. ab:
  91. ab -kc 10 -t 60 http://localhost:8080/
  92. ab -kc 10 -t 60 http://localhost:8080/blog/
  93. ab -kc 10 -t 60 http://localhost:8080/blog/category/health-and-food/
  94. ab -kc 10 -t 60 http://localhost:8080/blog/the-best-juices-for-a-child/
  95. ab -kc 10 -t 60 http://localhost:8080/shop/
  96. ab -kc 10 -t 60 http://localhost:8080/shop/category/electronics/
  97. ab -kc 10 -t 60 http://localhost:8080/shop/samsung-galaxy-s10/