diff --git a/README-cn.md b/README-cn.md index 78aac58..d1be61c 100644 --- a/README-cn.md +++ b/README-cn.md @@ -68,20 +68,20 @@ DTM是一款golang开发的分布式事务管理器,解决了跨数据库、 ### 获取代码 -`git clone https://github.com/yedf/dtm` +`git clone https://github.com/yedf/dtm && cd dtm` ### dtm依赖于mysql 安装[docker 20.04+](https://docs.docker.com/get-docker/)之后 -`docker-compose helper/compose.mysql.yml` +`docker-compose -f helper/compose.mysql.yml up` > 您也可以配置使用现有的mysql,需要高级权限,允许dtm创建数据库 > > `cp conf.sample.yml conf.yml # 修改conf.yml` ### 启动并运行saga示例 -`go run app/main.go saga` +`go run app/main.go qs` ## 开始使用 diff --git a/README.md b/README.md index ea51ca5..d1be61c 100644 --- a/README.md +++ b/README.md @@ -66,18 +66,22 @@ DTM是一款golang开发的分布式事务管理器,解决了跨数据库、 ## 快速开始 -### 安装 +### 获取代码 -`git clone https://github.com/yedf/dtm` +`git clone https://github.com/yedf/dtm && cd dtm` ### dtm依赖于mysql -配置mysql: +安装[docker 20.04+](https://docs.docker.com/get-docker/)之后 -`cp conf.sample.yml conf.yml # 修改conf.yml` +`docker-compose -f helper/compose.mysql.yml up` + +> 您也可以配置使用现有的mysql,需要高级权限,允许dtm创建数据库 +> +> `cp conf.sample.yml conf.yml # 修改conf.yml` ### 启动并运行saga示例 -`go run app/main.go saga` +`go run app/main.go qs` ## 开始使用 diff --git a/docker-compose.yml b/docker-compose.yml index 3918e6d..85a4429 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,6 +8,8 @@ services: - '8080:8080' volumes: - .:/app/work + - /etc/localtime:/etc/localtime:ro + - /etc/timezone:/etc/timezone:ro command: ['/app/dtm/main', 'dev'] working_dir: /app/work extra_hosts: @@ -16,12 +18,13 @@ services: image: 'mysql:5.7' environment: MYSQL_ALLOW_EMPTY_PASSWORD: 1 - TZ: Asia/shanghai + volumes: + - /etc/localtime:/etc/localtime:ro + - /etc/timezone:/etc/timezone:ro command: [ '--character-set-server=utf8mb4', '--collation-server=utf8mb4_unicode_ci', - '--default-time-zone=+8:00', ] ports: - '3306:3306' diff --git a/helper/compose.cloud.yml b/helper/compose.cloud.yml index 9d65062..1336052 100644 --- a/helper/compose.cloud.yml +++ b/helper/compose.cloud.yml @@ -2,6 +2,11 @@ version: '3.3' services: api: build: .. + volumes: + - /etc/localtime:/etc/localtime:ro + - /etc/timezone:/etc/timezone:ro + extra_hosts: + - 'host.docker.internal:host-gateway' environment: IS_DOCKER: 1 DISABLE_LOCALHOST: 1 @@ -12,14 +17,15 @@ services: - ..:/app/dtm mysql: image: 'mysql:5.7' + volumes: + - /etc/localtime:/etc/localtime:ro + - /etc/timezone:/etc/timezone:ro environment: MYSQL_ALLOW_EMPTY_PASSWORD: 1 - TZ: Asia/shanghai command: [ '--character-set-server=utf8mb4', '--collation-server=utf8mb4_unicode_ci', - '--default-time-zone=+8:00', ] ports: - '3306:3306' diff --git a/helper/docker-compose.dev.yml b/helper/compose.dev.yml similarity index 68% rename from helper/docker-compose.dev.yml rename to helper/compose.dev.yml index 77e18a9..d904d35 100644 --- a/helper/docker-compose.dev.yml +++ b/helper/compose.dev.yml @@ -2,11 +2,17 @@ version: '3.3' services: api: image: golang:1.16.6-alpine3.14 + extra_hosts: + - 'host.docker.internal:host-gateway' + volumes: + - /etc/localtime:/etc/localtime:ro + - /etc/timezone:/etc/timezone:ro environment: IS_DOCKER: '1' GOPROXY: 'https://mirrors.aliyun.com/goproxy/,direct' ports: - '8080:8080' + - '8082:8082' - '58080:58080' volumes: - ..:/app/work @@ -14,14 +20,15 @@ services: working_dir: /app/work mysql: image: 'mysql:5.7' + volumes: + - /etc/localtime:/etc/localtime:ro + - /etc/timezone:/etc/timezone:ro environment: MYSQL_ALLOW_EMPTY_PASSWORD: 1 - TZ: Asia/shanghai command: [ '--character-set-server=utf8mb4', '--collation-server=utf8mb4_unicode_ci', - '--default-time-zone=+8:00', ] ports: - '3306:3306' diff --git a/helper/compose.mysql.yml b/helper/compose.mysql.yml index c640fa0..0c5ec71 100644 --- a/helper/compose.mysql.yml +++ b/helper/compose.mysql.yml @@ -2,14 +2,15 @@ version: '3.3' services: mysql: image: 'mysql:5.7' + volumes: + - /etc/localtime:/etc/localtime:ro + - /etc/timezone:/etc/timezone:ro environment: MYSQL_ALLOW_EMPTY_PASSWORD: 1 - TZ: Asia/shanghai command: [ '--character-set-server=utf8mb4', '--collation-server=utf8mb4_unicode_ci', - '--default-time-zone=+8:00', ] ports: - '3306:3306' diff --git a/helper/compose.postgres.yml b/helper/compose.postgres.yml index 11b409e..dc80e61 100644 --- a/helper/compose.postgres.yml +++ b/helper/compose.postgres.yml @@ -3,6 +3,9 @@ services: postgres: image: 'postgres:13' command: postgres --max_prepared_transactions=1000 + volumes: + - /etc/localtime:/etc/localtime:ro + - /etc/timezone:/etc/timezone:ro environment: POSTGRES_PASSWORD: mysecretpassword diff --git a/helper/compose.qs.yml b/helper/compose.qs.yml new file mode 100644 index 0000000..2b50a8b --- /dev/null +++ b/helper/compose.qs.yml @@ -0,0 +1,32 @@ +version: '3.3' +services: + api: + image: 'yedf/dtm' + environment: + IS_DOCKER: '1' + ports: + - '8080:8080' + - '8082:8082' + - '58080:58080' + volumes: + - ..:/app/work + - /etc/localtime:/etc/localtime:ro + - /etc/timezone:/etc/timezone:ro + command: ['/app/dtm/main', 'qs'] + working_dir: /app/work + extra_hosts: + - 'host.docker.internal:host-gateway' + db: + image: 'mysql:5.7' + environment: + MYSQL_ALLOW_EMPTY_PASSWORD: 1 + volumes: + - /etc/localtime:/etc/localtime:ro + - /etc/timezone:/etc/timezone:ro + command: + [ + '--character-set-server=utf8mb4', + '--collation-server=utf8mb4_unicode_ci', + ] + ports: + - '3306:3306'