From 4eea78f8ed3c494501216ec30eb00dc5a42e13ed Mon Sep 17 00:00:00 2001 From: markliu2013 Date: Wed, 24 Jan 2024 23:18:19 +0800 Subject: [PATCH] save --- README.md | 59 +++++++++++++++++++++++++++------ docker-compose-ali-no-mysql.yml | 3 ++ docker-compose-ali.yml | 9 +++-- docker-compose-hub-no-mysql.yml | 3 ++ docker-compose-hub.yml | 10 ++++-- docker-compose-no-mysql.yml | 3 ++ docker-compose.yml | 5 +-- notes.txt | 25 ++++++++++++-- 8 files changed, 97 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index ec2c336..e0b7e98 100644 --- a/README.md +++ b/README.md @@ -4,42 +4,79 @@ 部署前,请确保已安装docker compose。如遇到任何问题欢迎加入 QQ群: 639653091 讨论。 -部署步骤: +### 部署步骤: 1. 请下载本项目源代码,使用git命令或直接下载源代码。 ```sh git clone https://github.com/getmoneynote/docker-compose-moneywhere.git && cd docker-compose-moneywhere ``` -2. 为保证数据安全问题,请修改数据库默认密码,一共2个地方需要修改。 - 1. docker-compose.yml文件 MYSQL_ROOT_PASSWORD变量 - 2. api.env DB_PASSWORD变量修改 -3. 为防止恶意注册,请修改默认邀请码。api.env文件,invite_code变量修改 +2. 为保证数据安全问题,请修改数据库默认密码。api.env -> DB_PASSWORD +3. 为防止恶意注册,请修改默认邀请码。api.env -> invite_code 4. 执行命令 ```sh -docker compose up -d +docker compose --env-file api.env up -d ``` -如果已有mysql服务,想使用已存在的mysql服务,请修改项目的mysql相关配置,执行命令 +如果已有mysql服务,想使用已存在的mysql服务,请修改api-no-mysql.env文件为对应数据库信息,执行命令 ```sh -docker compose -f docker-compose-no-mysql.yml up -d +docker compose --env-file api-no-mysql.env -f docker-compose-no-mysql.yml up -d ``` 默认使用Docker Hub官方网站镜像,中国大陆可能出现无法拉去镜像,可尝试使用阿里云镜像。项目运行后,本身不依赖任何外部第三方服务。 ```sh -docker compose -f docker-compose-ali.yml up -d +docker compose --env-file api.env -f docker-compose-ali.yml up -d ``` 版本升级,使用最新镜像。 ```sh -docker compose pull && docker compose up -d +docker compose pull && docker compose --env-file api.env up -d ``` + + +#### docker命令说明 +docker hub with mysql 启动 ```sh -docker compose -f docker-compose-no-mysql.yml pull && docker compose -f docker-compose-no-mysql.yml up -d +docker compose --env-file api.env -f docker-compose-hub.yml up -d ``` +docker hub no mysql 启动 +```sh +docker-compose --env-file api-no-mysql -f docker-compose-hub-no-mysql.yml up -d +``` + +阿里云 with mysql 启动 +```sh +docker compose --env-file api.env -f docker-compose-ali.yml up -d +``` + +阿里云 no mysql 启动 +```sh +docker-compose --env-file api-no-mysql.env -f docker-compose-ali-no-mysql.yml up -d +``` + +docker hub with mysql 升级 +```sh +docker compose -f docker-compose-hub.yml pull && docker compose --env-file api.env -f docker-compose-hub.yml up -d +``` + +docker hub no mysql 升级 +```sh +docker compose -f docker-compose-hub-no-mysql.yml pull && docker-compose --env-file api-no-mysql -f docker-compose-hub-no-mysql.yml up -d +``` + +阿里云 with mysql 升级 +```sh +docker compose -f docker-compose-ali.yml pull && docker compose --env-file api.env -f docker-compose-ali.yml up -d +``` + +阿里云 no mysql 升级 +```sh +docker compose -f docker-compose-ali-no-mysql.yml pull && docker-compose --env-file api-no-mysql.env -f docker-compose-ali-no-mysql.yml up -d +``` + 成功运行后,访问 [http://127.0.0.1:43743](http://127.0.0.1:43743) 可以打开网页版记账程序,使用前请注册一个账户,默认的邀请码是111111(6个1), 为防止被恶意注册,请修改默认邀请码。 diff --git a/docker-compose-ali-no-mysql.yml b/docker-compose-ali-no-mysql.yml index 0c71ffa..7ffa5e1 100644 --- a/docker-compose-ali-no-mysql.yml +++ b/docker-compose-ali-no-mysql.yml @@ -4,6 +4,7 @@ services: moneywhere-api-user: container_name: moneywhere_api image: registry.cn-hangzhou.aliyuncs.com/moneywhere/moneywhere-api-user:latest + restart: always extra_hosts: - "host.docker.internal:host-gateway" env_file: api-no-mysql.env @@ -15,6 +16,7 @@ services: links: - moneywhere-api-user image: registry.cn-hangzhou.aliyuncs.com/moneywhere/moneywhere-fe-user:latest + restart: always environment: USER_API_HOST: http://moneywhere-api-user:9092 ports: @@ -25,6 +27,7 @@ services: links: - moneywhere-api-user image: registry.cn-hangzhou.aliyuncs.com/moneywhere/moneywhere-fe-user-mobile:latest + restart: always environment: USER_API_HOST: http://moneywhere-api-user:9092 ports: diff --git a/docker-compose-ali.yml b/docker-compose-ali.yml index 9d33be6..9449231 100644 --- a/docker-compose-ali.yml +++ b/docker-compose-ali.yml @@ -4,10 +4,12 @@ services: mysql: container_name: moneywhere_mysql image: registry.cn-hangzhou.aliyuncs.com/moneywhere/mysql:5.7 + env_file: + - api.env restart: always environment: - MYSQL_ROOT_PASSWORD: 111111 - MYSQL_DATABASE: moneywhere + - MYSQL_ROOT_PASSWORD=${DB_PASSWORD} + - MYSQL_DATABASE=${DB_NAME} command: [ '--character-set-server=utf8mb4', '--collation-server=utf8mb4_general_ci', @@ -35,6 +37,7 @@ services: links: - mysql image: registry.cn-hangzhou.aliyuncs.com/moneywhere/moneywhere-api-user:latest + restart: always env_file: api.env ports: - "43742:9092" @@ -44,6 +47,7 @@ services: links: - moneywhere-api-user image: registry.cn-hangzhou.aliyuncs.com/moneywhere/moneywhere-fe-user:latest + restart: always environment: USER_API_HOST: http://moneywhere-api-user:9092 ports: @@ -54,6 +58,7 @@ services: links: - moneywhere-api-user image: registry.cn-hangzhou.aliyuncs.com/moneywhere/moneywhere-fe-user-mobile:latest + restart: always environment: USER_API_HOST: http://moneywhere-api-user:9092 ports: diff --git a/docker-compose-hub-no-mysql.yml b/docker-compose-hub-no-mysql.yml index aeea636..6bbc899 100644 --- a/docker-compose-hub-no-mysql.yml +++ b/docker-compose-hub-no-mysql.yml @@ -4,6 +4,7 @@ services: moneywhere-api-user: container_name: moneywhere_api image: markliu2018/moneywhere-api-user:latest + restart: always extra_hosts: - "host.docker.internal:host-gateway" env_file: api-no-mysql.env @@ -15,6 +16,7 @@ services: links: - moneywhere-api-user image: markliu2018/moneywhere-fe-user:latest + restart: always environment: USER_API_HOST: http://moneywhere-api-user:9092 ports: @@ -25,6 +27,7 @@ services: links: - moneywhere-api-user image: markliu2018/moneywhere-fe-user-mobile:latest + restart: always environment: USER_API_HOST: http://moneywhere-api-user:9092 ports: diff --git a/docker-compose-hub.yml b/docker-compose-hub.yml index fc169f3..1241886 100644 --- a/docker-compose-hub.yml +++ b/docker-compose-hub.yml @@ -4,10 +4,11 @@ services: mysql: container_name: moneywhere_mysql image: mysql:5.7 + env_file: api.env restart: always environment: - MYSQL_ROOT_PASSWORD: 111111 - MYSQL_DATABASE: moneywhere + MYSQL_ROOT_PASSWORD: ${DB_PASSWORD} + MYSQL_DATABASE: ${DB_NAME} command: [ '--character-set-server=utf8mb4', '--collation-server=utf8mb4_general_ci', @@ -22,11 +23,11 @@ services: phpmyadmin: container_name: moneywhere_phpmyadmin image: phpmyadmin/phpmyadmin + restart: always links: - mysql environment: PMA_ARBITRARY: 1 - restart: always ports: - "43741:80" @@ -35,6 +36,7 @@ services: links: - mysql image: markliu2018/moneywhere-api-user:latest + restart: always env_file: api.env ports: - "43742:9092" @@ -44,6 +46,7 @@ services: links: - moneywhere-api-user image: markliu2018/moneywhere-fe-user:latest + restart: always environment: USER_API_HOST: http://moneywhere-api-user:9092 ports: @@ -54,6 +57,7 @@ services: links: - moneywhere-api-user image: markliu2018/moneywhere-fe-user-mobile:latest + restart: always environment: USER_API_HOST: http://moneywhere-api-user:9092 ports: diff --git a/docker-compose-no-mysql.yml b/docker-compose-no-mysql.yml index aeea636..6bbc899 100644 --- a/docker-compose-no-mysql.yml +++ b/docker-compose-no-mysql.yml @@ -4,6 +4,7 @@ services: moneywhere-api-user: container_name: moneywhere_api image: markliu2018/moneywhere-api-user:latest + restart: always extra_hosts: - "host.docker.internal:host-gateway" env_file: api-no-mysql.env @@ -15,6 +16,7 @@ services: links: - moneywhere-api-user image: markliu2018/moneywhere-fe-user:latest + restart: always environment: USER_API_HOST: http://moneywhere-api-user:9092 ports: @@ -25,6 +27,7 @@ services: links: - moneywhere-api-user image: markliu2018/moneywhere-fe-user-mobile:latest + restart: always environment: USER_API_HOST: http://moneywhere-api-user:9092 ports: diff --git a/docker-compose.yml b/docker-compose.yml index 7e0c74b..f503f92 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,10 +4,11 @@ services: mysql: container_name: moneywhere_mysql image: mysql:5.7 + env_file: api.env restart: always environment: - MYSQL_ROOT_PASSWORD: 111111 - MYSQL_DATABASE: moneywhere + MYSQL_ROOT_PASSWORD: ${DB_PASSWORD} + MYSQL_DATABASE: ${DB_NAME} command: [ '--character-set-server=utf8mb4', '--collation-server=utf8mb4_general_ci', diff --git a/notes.txt b/notes.txt index b27e7e4..82f8392 100644 --- a/notes.txt +++ b/notes.txt @@ -1,2 +1,23 @@ -docker-compose -f docker-compose-hub.yml up -d -docker-compose -f docker-compose-no-mysql.yml up -d +docker hub with mysql 启动 +docker compose --env-file api.env -f docker-compose-hub.yml up -d + +docker hub no mysql 启动 +docker-compose --env-file api-no-mysql -f docker-compose-hub-no-mysql.yml up -d + +阿里云 with mysql 启动 +docker compose --env-file api.env -f docker-compose-ali.yml up -d + +阿里云 no mysql 启动 +docker-compose --env-file api-no-mysql.env -f docker-compose-ali-no-mysql.yml up -d + +docker hub with mysql 升级 +docker compose -f docker-compose-hub.yml pull && docker compose --env-file api.env -f docker-compose-hub.yml up -d + +docker hub no mysql 升级 +docker compose -f docker-compose-hub-no-mysql.yml pull && docker-compose --env-file api-no-mysql -f docker-compose-hub-no-mysql.yml up -d + +阿里云 with mysql 升级 +docker compose -f docker-compose-ali.yml pull && docker compose --env-file api.env -f docker-compose-ali.yml up -d + +阿里云 no mysql 升级 +docker compose -f docker-compose-ali-no-mysql.yml pull && docker-compose --env-file api-no-mysql.env -f docker-compose-ali-no-mysql.yml up -d