Makefile 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. VERSION="1.6.0"
  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 ./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" > engine/consts/consts_version.go
  44. @echo "" >> engine/consts/consts_version.go
  45. @echo "const ServerVersion = \"${VERSION}\"" >> engine/consts/consts_version.go
  46. template:
  47. @./support/template.sh
  48. @gofmt -w ./engine/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 "ARG DEBIAN_FRONTEND=noninteractive" >> Dockerfile
  59. @echo "" >> Dockerfile
  60. @echo "RUN apt-get -y update && apt-get -y upgrade && \\" >> Dockerfile
  61. @echo " apt-get install -y ca-certificates && \\" >> Dockerfile
  62. @echo " dpkg-reconfigure -p critical ca-certificates && \\" >> Dockerfile
  63. @echo " tar -zxf /app/fave.linux-amd64.tar.gz -C /app && \\" >> Dockerfile
  64. @echo " tar -zxf /app/hosts/localhost.tar.gz -C /app/hosts && \\" >> Dockerfile
  65. @echo " rm /app/fave.linux-amd64.tar.gz && \\" >> Dockerfile
  66. @echo " rm /app/hosts/localhost.tar.gz && \\" >> Dockerfile
  67. @echo " mkdir /app/src && cp -R /app/hosts/localhost /app/src && \\" >> Dockerfile
  68. @echo " chmod +x /app/fave.linux-amd64" >> Dockerfile
  69. @echo "" >> Dockerfile
  70. @echo "EXPOSE 8080" >> Dockerfile
  71. @echo "VOLUME /app/hosts" >> Dockerfile
  72. @echo "" >> Dockerfile
  73. @echo "CMD /app/fave.linux-amd64" >> Dockerfile
  74. docker-test: dockerfile
  75. @-docker stop fave-test
  76. @-docker rm fave-test
  77. @-docker rmi fave
  78. docker build --rm=false --force-rm=true -t fave:latest .
  79. docker run --rm --name fave-test --cpus=".2" -m 200m -p 8080:8080 -t -i fave:latest /app/fave.linux-amd64
  80. @-docker rmi fave:latest
  81. docker-img: dockerfile
  82. docker build -t fave:latest .
  83. docker-push: docker-img
  84. docker tag fave:latest vladimirok5959/fave:${VERSION}
  85. docker tag fave:latest vladimirok5959/fave:latest
  86. docker login
  87. docker push vladimirok5959/fave:${VERSION}
  88. docker push vladimirok5959/fave:latest
  89. docker rmi vladimirok5959/fave:${VERSION}
  90. docker rmi vladimirok5959/fave:latest
  91. docker rmi fave:latest
  92. docker-clr:
  93. @-docker stop fave-test
  94. @-docker rm fave-test
  95. @-docker rmi fave
  96. migrate:
  97. ./support/migrate.sh