Makefile 4.0 KB

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