docker-compose.dev.yaml 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. # 1.Prepare your workspace by:
  2. # docker compose -f docker-compose.dev.yaml run api go install github.com/cosmtrek/air@latest
  3. # docker compose -f docker-compose.dev.yaml run web npm install
  4. #
  5. # 2. Start you work by:
  6. # docker compose up -d
  7. #
  8. # 3. Check logs by:
  9. # docker compose logs -f
  10. #
  11. services:
  12. db:
  13. image: mysql
  14. volumes:
  15. - ./.air/mysql:/var/lib/mysql
  16. api:
  17. image: golang:1.21-alpine
  18. working_dir: /work
  19. command: air -c ./scripts/.air.toml
  20. environment:
  21. - "MEMOS_DSN=root@tcp(db)/memos"
  22. - "MEMOS_DRIVER=mysql"
  23. volumes:
  24. - $HOME/go/pkg/:/go/pkg/ # Cache for go mod shared with the host
  25. - ./.air/bin/:/go/bin/ # Cache for binary used only in container, such as *air*
  26. - .:/work/
  27. web:
  28. image: node:18-alpine
  29. working_dir: /work
  30. depends_on: ["api"]
  31. ports: ["3001:3001"]
  32. environment: ["DEV_PROXY_SERVER=http://api:8081/"]
  33. command: npm run dev
  34. volumes:
  35. - ./web:/work
  36. - ./.air/node_modules/:/work/node_modules/ # Cache for Node Modules
  37. # Services below are used for developers to run once
  38. #
  39. # You can just run `docker compose run --rm SERVICE_NAME` to use
  40. # For example:
  41. # To regenerate typescript code of gRPC proto
  42. # Just run `docker compose run --rm buf`
  43. #
  44. # All of theses services belongs to profile 'tools'
  45. # This will prevent to launch by normally `docker compose up` unexpectly
  46. # Generate typescript code of gRPC proto
  47. buf:
  48. profiles: ["tools"]
  49. image: bufbuild/buf
  50. working_dir: /work/proto
  51. command: generate
  52. volumes:
  53. - ./proto:/work/proto
  54. - ./web/src/types/:/work/web/src/types/
  55. # Do golang static code check before create PR
  56. golangci-lint:
  57. profiles: ["tools"]
  58. image: golangci/golangci-lint:v1.54.2
  59. working_dir: /work/
  60. command: golangci-lint run -v
  61. volumes:
  62. - $HOME/go/pkg/:/go/pkg/ # Cache for go mod shared with the host
  63. - .:/work/
  64. # Do javascript lint before create PR
  65. lint:
  66. profiles: ["tools"]
  67. image: node:18-alpine
  68. working_dir: /work
  69. command: npm run lint
  70. volumes:
  71. - ./web:/work
  72. - ./.air/node_modules/:/work/node_modules/