-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add docker-compose.yml #14
base: master
Are you sure you want to change the base?
Conversation
environment: | ||
- MYSQL_ROOT_PASSWORD=root | ||
volumes: # 将容器的目录映射到宿主机上目录中 | ||
- "./db:/docker-entrypoint-initdb.d/" # 启动时自动执行db下的sql文件 |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里会提示 ERROR 1046 (3D000) at line 3: No database selected
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
建议整合db下的init.sql文件为以下内容,因为这里"./db:/docker-entrypoint-initdb.d/"是指定在启动mysql时自动执行db下的sql文件,我看你初始数据库的操作在init_unittest_db.sh文件中
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-- 创建数据库
DROP DATABASE IF EXISTS xprofiler_console_unittest
;
CREATE DATABASE xprofiler_console_unittest
;
DROP DATABASE IF EXISTS xprofiler_logs_unittest
;
CREATE DATABASE xprofiler_logs_unittest
;
-- 切换到数据库
use xprofiler_console_unittest;
-- 在数据库中建表
DROP TABLE IF EXISTS user
;
CREATE TABLE user
(
id
INT UNSIGNED AUTO_INCREMENT COMMENT 'unique auto increment id',
name
VARCHAR(100) NOT NULL COMMENT 'user name',
nick
VARCHAR(100) NOT NULL COMMENT 'user nick name',
pass
VARCHAR(200) NOT NULL COMMENT 'user pass key',
identity
VARCHAR(20) NOT NULL COMMENT 'user identity sign',
mail
VARCHAR(250) NOT NULL COMMENT 'user mail address',
gm_modified
DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'system modify timestamp',
gm_create
DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT 'system create timestamp',
PRIMARY KEY (id
),
UNIQUE KEY (name
),
UNIQUE KEY (identity
)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT 'user info table';
DROP TABLE IF EXISTS apps
;
CREATE TABLE apps
(
id
INT UNSIGNED AUTO_INCREMENT COMMENT 'unique auto increment id',
name
VARCHAR(50) NOT NULL COMMENT 'app name',
owner
INT UNSIGNED NOT NULL COMMENT 'owner user unique id',
secret
VARCHAR(50) NOT NULL COMMENT 'app secret key',
gm_modified
DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'system modify timestamp',
gm_create
DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT 'system create timestamp',
PRIMARY KEY (id
),
UNIQUE KEY (owner
, name
),
INDEX (owner
)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT 'app info table';
DROP TABLE IF EXISTS members
;
CREATE TABLE members
(
id
INT UNSIGNED AUTO_INCREMENT COMMENT 'unique auto increment id',
app
INT UNSIGNED NOT NULL COMMENT 'app unique id',
user
INT UNSIGNED NOT NULL COMMENT 'user unique id',
status
INT UNSIGNED NOT NULL COMMENT '1: inviting, 2: joined',
gm_modified
DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'system modify timestamp',
gm_create
DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT 'system create timestamp',
PRIMARY KEY (id
),
UNIQUE KEY (app
, user
)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT 'app members info table';
DROP TABLE IF EXISTS files
;
CREATE TABLE files
(
id
INT UNSIGNED AUTO_INCREMENT COMMENT 'unique auto increment id',
app
INT NOT NULL COMMENT 'app unique id',
agent
VARCHAR(50) NOT NULL COMMENT 'agent name',
type
VARCHAR(50) NOT NULL COMMENT 'file type',
file
VARCHAR(250) NOT NULL COMMENT 'file path',
storage
VARCHAR(250) DEFAULT "" COMMENT 'file storage path with custom',
user
INT UNSIGNED NOT NULL COMMENT 'user unique id',
status
TINYINT UNSIGNED DEFAULT 0 COMMENT '0:creating, 1:created, 2:transferring, 3:transferred',
favor
TINYINT UNSIGNED DEFAULT 0 COMMENT '0:not favor, 1:has favor',
token
VARCHAR(50) DEFAULT "" COMMENT 'file token',
gm_modified
DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'system modify timestamp',
gm_create
DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT 'system create timestamp',
PRIMARY KEY (id
),
UNIQUE KEY (app
, agent
, file
, storage
),
INDEX (id
, app
, type
)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT 'analyse file info table';
DROP TABLE IF EXISTS coredumps
;
CREATE TABLE coredumps
(
id
INT UNSIGNED AUTO_INCREMENT COMMENT 'unique auto increment id',
app
INT NOT NULL COMMENT 'app unique id',
agent
VARCHAR(50) NOT NULL COMMENT 'agent name',
file
VARCHAR(250) NOT NULL COMMENT 'file path',
file_storage
VARCHAR(250) DEFAULT "" COMMENT 'file storage with custom',
file_status
TINYINT UNSIGNED DEFAULT 0 COMMENT '0:creating, 1:created, 2:transferring, 3:transferred',
node
VARCHAR(250) NOT NULL COMMENT 'node path',
node_storage
VARCHAR(250) DEFAULT "" COMMENT 'node name',
node_status
TINYINT UNSIGNED DEFAULT 0 COMMENT '0:creating, 1:created, 2:transferring, 3:transferred',
user
INT UNSIGNED NOT NULL COMMENT 'user unique id',
favor
TINYINT UNSIGNED DEFAULT 0 COMMENT '0:not favor, 1:has favor',
token
VARCHAR(50) DEFAULT "" COMMENT 'file token',
gm_modified
DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'system modify timestamp',
gm_create
DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT 'system create timestamp',
PRIMARY KEY (id
),
UNIQUE KEY (app
, agent
, file
, file_storage
),
INDEX (id
, app
)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT 'coredumps info table';
DROP TABLE IF EXISTS strategies
;
CREATE TABLE strategies
(
id
INT UNSIGNED AUTO_INCREMENT COMMENT 'unique auto increment id',
app
INT NOT NULL COMMENT 'app unique id',
context
VARCHAR(50) NOT NULL COMMENT 'context type',
push
VARCHAR(50) NOT NULL COMMENT 'push level',
webhook
TINYINT UNSIGNED DEFAULT 0 COMMENT '0:close, 1:open',
wtype
VARCHAR(20) DEFAULT '' COMMENT 'webhook type',
waddress
VARCHAR(200) DEFAULT '' COMMENT 'webhook address',
wsign
VARCHAR(100) DEFAULT '' COMMENT 'webhook sign',
expression
VARCHAR(150) NOT NULL COMMENT 'alarm expression',
content
VARCHAR(150) NOT NULL COMMENT 'alarm content',
status
TINYINT UNSIGNED DEFAULT 1 COMMENT '0:disable, 1:enable',
gm_modified
DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'system modify timestamp',
gm_create
DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT 'system create timestamp',
PRIMARY KEY (id
),
INDEX (id
, app
)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT 'strategies info table';
DROP TABLE IF EXISTS contacts
;
CREATE TABLE contacts
(
id
INT UNSIGNED AUTO_INCREMENT COMMENT 'unique auto increment id',
strategy
INT UNSIGNED NOT NULL COMMENT 'strategy unique id',
user
INT UNSIGNED NOT NULL COMMENT 'user unique id',
gm_modified
DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'system modify timestamp',
gm_create
DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT 'system create timestamp',
PRIMARY KEY (id
),
UNIQUE KEY (strategy
, user
),
INDEX (strategy
)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT 'strategy contacts info table';
最好再补个 quick start 的步骤,我放到文档里。 |
按照刚刚提到的,修改下db/init.sql的文件内容,即可按照以下步骤快速启动项目。
|
我明白了,这个 docker-compose.yml 只是将依赖的 db/redis 做了初始化,那为什么需要多一层 service |
This comment has been minimized.
This comment has been minimized.
这个 docker 内的 node 没法直接在宿主机上使用吧?要 exec 到对应的容器内才能用 |
另外,我测试了下会提示 egg-mysql 的版本过低,我看这个 file 里默认会安装 mysql@8,egg-mysql 貌似不支持 |
版本问题是因为mysql8的密码加密方式改了,需要改一下加密方式 可以参考 https://blog.csdn.net/qq_26819733/article/details/80794047 |
这样电脑可以不用安装node、mysql、redis等环境,直接运行本项目。