2023-05-29 19:49:47 +08:00
|
|
|
services:
|
2023-09-28 22:09:52 +08:00
|
|
|
db:
|
|
|
|
image: mysql
|
|
|
|
volumes:
|
|
|
|
- ./.air/mysql:/var/lib/mysql
|
2023-05-29 19:49:47 +08:00
|
|
|
api:
|
2023-10-07 21:24:53 +08:00
|
|
|
image: cosmtrek/air
|
2023-05-29 19:49:47 +08:00
|
|
|
working_dir: /work
|
2023-10-07 21:24:53 +08:00
|
|
|
command: ["-c", "./scripts/.air.toml"]
|
2023-09-28 22:09:52 +08:00
|
|
|
environment:
|
|
|
|
- "MEMOS_DSN=root@tcp(db)/memos"
|
|
|
|
- "MEMOS_DRIVER=mysql"
|
2023-05-29 19:49:47 +08:00
|
|
|
volumes:
|
|
|
|
- .:/work/
|
2023-10-27 21:21:52 +08:00
|
|
|
- .air/go-build:/root/.cache/go-build
|
2023-10-07 21:24:53 +08:00
|
|
|
- $HOME/go/pkg/:/go/pkg/ # Cache for go mod shared with the host
|
2023-05-29 19:49:47 +08:00
|
|
|
web:
|
2023-08-27 16:08:39 +08:00
|
|
|
image: node:18-alpine
|
2023-05-29 19:49:47 +08:00
|
|
|
working_dir: /work
|
|
|
|
depends_on: ["api"]
|
|
|
|
ports: ["3001:3001"]
|
|
|
|
environment: ["DEV_PROXY_SERVER=http://api:8081/"]
|
2023-10-07 21:24:53 +08:00
|
|
|
entrypoint: ["/bin/sh", "-c"]
|
|
|
|
command: ["corepack enable && pnpm install && pnpm dev"]
|
2023-05-29 19:49:47 +08:00
|
|
|
volumes:
|
|
|
|
- ./web:/work
|
|
|
|
- ./.air/node_modules/:/work/node_modules/ # Cache for Node Modules
|
2023-09-28 22:54:11 +08:00
|
|
|
|
|
|
|
# Services below are used for developers to run once
|
|
|
|
#
|
|
|
|
# You can just run `docker compose run --rm SERVICE_NAME` to use
|
|
|
|
# For example:
|
|
|
|
# To regenerate typescript code of gRPC proto
|
|
|
|
# Just run `docker compose run --rm buf`
|
|
|
|
#
|
|
|
|
# All of theses services belongs to profile 'tools'
|
|
|
|
# This will prevent to launch by normally `docker compose up` unexpectly
|
|
|
|
|
|
|
|
# Generate typescript code of gRPC proto
|
|
|
|
buf:
|
|
|
|
profiles: ["tools"]
|
|
|
|
image: bufbuild/buf
|
|
|
|
working_dir: /work/proto
|
|
|
|
command: generate
|
|
|
|
volumes:
|
|
|
|
- ./proto:/work/proto
|
|
|
|
- ./web/src/types/:/work/web/src/types/
|
|
|
|
|
|
|
|
# Do golang static code check before create PR
|
|
|
|
golangci-lint:
|
|
|
|
profiles: ["tools"]
|
|
|
|
image: golangci/golangci-lint:v1.54.2
|
|
|
|
working_dir: /work/
|
2023-10-27 21:21:52 +08:00
|
|
|
entrypoint: golangci-lint
|
|
|
|
command: run -v
|
2023-09-28 22:54:11 +08:00
|
|
|
volumes:
|
|
|
|
- $HOME/go/pkg/:/go/pkg/ # Cache for go mod shared with the host
|
2023-10-27 21:21:52 +08:00
|
|
|
- .air/go-build:/root/.cache/go-build
|
2023-09-28 22:54:11 +08:00
|
|
|
- .:/work/
|
|
|
|
|
2023-10-27 21:21:52 +08:00
|
|
|
# run npm
|
|
|
|
npm:
|
2023-09-28 22:54:11 +08:00
|
|
|
profiles: ["tools"]
|
|
|
|
image: node:18-alpine
|
|
|
|
working_dir: /work
|
2023-10-27 21:21:52 +08:00
|
|
|
environment: ["NPM_CONFIG_UPDATE_NOTIFIER=false"]
|
|
|
|
entrypoint: "npm"
|
2023-09-28 22:54:11 +08:00
|
|
|
volumes:
|
|
|
|
- ./web:/work
|
|
|
|
- ./.air/node_modules/:/work/node_modules/
|