docker-compose.dev.yaml 1.9 KB

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