1
0

Makefile 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. # Copyright (c) 2020 Docker Inc.
  2. # Permission is hereby granted, free of charge, to any person
  3. # obtaining a copy of this software and associated documentation
  4. # files (the "Software"), to deal in the Software without
  5. # restriction, including without limitation the rights to use, copy,
  6. # modify, merge, publish, distribute, sublicense, and/or sell copies
  7. # of the Software, and to permit persons to whom the Software is
  8. # furnished to do so, subject to the following conditions:
  9. # The above copyright notice and this permission notice shall be
  10. # included in all copies or substantial portions of the Software.
  11. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  12. # EXPRESS OR IMPLIED,
  13. # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  15. # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  16. # HOLDERS BE LIABLE FOR ANY CLAIM,
  17. # DAMAGES OR OTHER LIABILITY,
  18. # WHETHER IN AN ACTION OF CONTRACT,
  19. # TORT OR OTHERWISE,
  20. # ARISING FROM, OUT OF OR IN CONNECTION WITH
  21. # THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22. GIT_COMMIT=$(shell git rev-parse --short HEAD)
  23. GOOS ?= $(shell go env GOOS)
  24. GOARCH ?= $(shell go env GOARCH)
  25. PROTOS=$(shell find . -name \*.proto)
  26. export DOCKER_BUILDKIT=1
  27. all: dbins
  28. xall: dxbins
  29. bins: cli example
  30. xbins: xcli xexample
  31. protos:
  32. @protoc -I. --go_out=plugins=grpc,paths=source_relative:. ${PROTOS}
  33. cli: protos
  34. cd cmd && GOOS=${GOOS} GOARCH=${GOARCH} go build -v -o ../bin/docker
  35. example: protos
  36. cd example/backend && go build -v -o ../../bin/backend-example
  37. xcli: cli
  38. cd cmd && GOOS=linux GOARCH=amd64 go build -v -o ../bin/docker-linux-amd64
  39. cd cmd && GOOS=darwin GOARCH=amd64 go build -v -o ../bin/docker-darwin-amd64
  40. cd cmd && GOOS=windows GOARCH=amd64 go build -v -o ../bin/docker-windows-amd64.exe
  41. xexample: example
  42. cd example/backend && GOOS=linux GOARCH=amd64 go build -v -o ../../bin/backend-example-linux-amd64
  43. cd example/backend && GOOS=darwin GOARCH=amd64 go build -v -o ../../bin/backend-example-darwin-amd64
  44. cd example/backend && GOOS=windows GOARCH=amd64 go build -v -o ../../bin/backend-example-windows-amd64.exe
  45. dprotos:
  46. docker build . \
  47. --output type=local,dest=./backend/v1 \
  48. --target protos
  49. dbins: dprotos
  50. docker build . \
  51. --output type=local,dest=./bin \
  52. --build-arg TARGET_OS=${GOOS} \
  53. --build-arg TARGET_ARCH=${GOARCH} \
  54. --target bins
  55. dxbins: dbins
  56. docker build . \
  57. --output type=local,dest=./bin \
  58. --target xbins
  59. FORCE:
  60. .PHONY: all xall protos example xexample xcli cli bins dbins dxbins dprotos