Makefile 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. VERSION="1.6.5"
  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 --color=always
  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 -R ./bin/localhost/htdocs/public
  27. @-rm ./bin/localhost/config/*
  28. @-rm ./bin/localhost/htdocs/*
  29. @-rm ./bin/localhost/logs/*
  30. @-rm ./bin/localhost/tmp/*
  31. cd ./bin && tar -zcf localhost.tar.gz ./localhost
  32. @-rm -r ./bin/localhost
  33. cp ./Dockerfile ./bin/Dockerfile
  34. cd ./bin && shasum -a 256 * > sha256sum.txt
  35. cat ./bin/sha256sum.txt
  36. clean:
  37. @-rm -r ./bin
  38. format:
  39. gofmt -w ./
  40. update:
  41. go mod vendor
  42. go mod download
  43. version:
  44. @echo "package consts" > engine/consts/consts_version.go
  45. @echo "" >> engine/consts/consts_version.go
  46. @echo "const ServerVersion = \"${VERSION}\"" >> engine/consts/consts_version.go
  47. template:
  48. @./support/template.sh
  49. @gofmt -w ./engine/assets/template/
  50. dockerfile:
  51. @echo "FROM debian:latest" > Dockerfile
  52. @echo "MAINTAINER Vova Tkach <vladimirok5959@gmail.com>" >> Dockerfile
  53. @echo "" >> Dockerfile
  54. @echo "ENV FAVE_HOST=0.0.0.0 FAVE_PORT=8080 FAVE_DIR=/app/hosts FAVE_DEBUG=false FAVE_KEEPALIVE=true" >> Dockerfile
  55. @echo "" >> Dockerfile
  56. @echo "ADD https://github.com/vladimirok5959/golang-fave/releases/download/v${VERSION}/fave.linux-amd64.tar.gz /app/fave.linux-amd64.tar.gz" >> Dockerfile
  57. @echo "ADD https://github.com/vladimirok5959/golang-fave/releases/download/v${VERSION}/localhost.tar.gz /app/hosts/localhost.tar.gz" >> Dockerfile
  58. @echo "" >> Dockerfile
  59. @echo "ARG DEBIAN_FRONTEND=noninteractive" >> Dockerfile
  60. @echo "" >> Dockerfile
  61. @echo "RUN apt-get -y update && apt-get -y upgrade && \\" >> Dockerfile
  62. @echo " apt-get install -y ca-certificates && \\" >> Dockerfile
  63. @echo " dpkg-reconfigure -p critical ca-certificates && \\" >> Dockerfile
  64. @echo " tar -zxf /app/fave.linux-amd64.tar.gz -C /app && \\" >> Dockerfile
  65. @echo " tar -zxf /app/hosts/localhost.tar.gz -C /app/hosts && \\" >> Dockerfile
  66. @echo " rm /app/fave.linux-amd64.tar.gz && \\" >> Dockerfile
  67. @echo " rm /app/hosts/localhost.tar.gz && \\" >> Dockerfile
  68. @echo " mkdir /app/src && cp -R /app/hosts/localhost /app/src && \\" >> Dockerfile
  69. @echo " chmod +x /app/fave.linux-amd64" >> Dockerfile
  70. @echo "" >> Dockerfile
  71. @echo "EXPOSE 8080" >> Dockerfile
  72. @echo "VOLUME /app/hosts" >> Dockerfile
  73. @echo "" >> Dockerfile
  74. @echo "CMD /app/fave.linux-amd64" >> Dockerfile
  75. docker-test: dockerfile
  76. @-docker stop fave-test
  77. @-docker rm fave-test
  78. @-docker rmi fave
  79. docker build --rm=false --force-rm=true -t fave:latest .
  80. docker run --rm --name fave-test --cpus=".2" -m 200m -p 8080:8080 -t -i fave:latest /app/fave.linux-amd64
  81. @-docker rmi fave:latest
  82. docker-img: dockerfile
  83. docker build -t fave:latest .
  84. docker-push: docker-img
  85. docker tag fave:latest vladimirok5959/fave:${VERSION}
  86. docker tag fave:latest vladimirok5959/fave:latest
  87. docker login
  88. docker push vladimirok5959/fave:${VERSION}
  89. docker push vladimirok5959/fave:latest
  90. docker rmi vladimirok5959/fave:${VERSION}
  91. docker rmi vladimirok5959/fave:latest
  92. docker rmi fave:latest
  93. docker-clr:
  94. @-docker stop fave-test
  95. @-docker rm fave-test
  96. @-docker rmi fave
  97. migrate:
  98. ./support/migrate.sh