Makefile 4.0 KB

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