Skip to content
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

Docker support #44

Merged
merged 33 commits into from
Aug 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
acec596
Merge branch 'develop'
shigma Feb 27, 2020
5664647
Merge branch 'develop'
shigma Mar 4, 2020
ff65e7e
Merge branch 'develop'
shigma Mar 11, 2020
4af70d1
Merge branch 'develop'
shigma Mar 15, 2020
df43b04
Create FUNDING.yml
shigma Mar 21, 2020
6abdef1
fix(core): fix shouldFetchUsage
shigma Mar 26, 2020
08bf402
fix(core): fix ws server broken by cqhttp 4.14
shigma Mar 26, 2020
6e6ff06
chore: bump version
shigma Mar 26, 2020
fe43409
dep: cac: ^6.5.7 -> 6.5.8, prompts: ^2.3.1 -> 2.3.2
shigma Mar 26, 2020
acaffac
Merge branch 'develop'
shigma Mar 26, 2020
5177f59
fix(core): fix ws server send (close: #35)
shigma Apr 18, 2020
b0d49f4
fix(core): handle anonymous message
shigma Apr 18, 2020
7328539
feat(plugin-common): support echo -a/-A
shigma Apr 18, 2020
542eb5f
feat(plugin-common): get group member info in contextify
shigma Apr 18, 2020
7d77728
fix(cli): check require stack when encountered with MODULE_NOT_FOUND
shigma Apr 18, 2020
04f7311
feat(core): support meta.$app
shigma Apr 18, 2020
10698d2
fix(core): fix non-negated options
shigma Apr 18, 2020
735877f
feat(core): strip quote on rest parameters and support single quotes
shigma Apr 18, 2020
26ba494
feat(utils): enhanced cqCode.stringify
shigma Apr 18, 2020
7ed1e7d
chore: tweak
shigma Apr 18, 2020
f70c9c9
feat(test-utils): attach sender to meta
shigma Apr 18, 2020
649d35a
fix(core): fix non-negated options
shigma Apr 18, 2020
ad4c0fa
bump version (escape-string-regexp 2->3)
shigma Apr 18, 2020
de0ebc0
Merge pull request #37 from koishijs/develop
shigma Apr 18, 2020
2acbba7
docker: create Dockerfile
NN708 Jun 27, 2020
fa68cb9
docker: use start.js to init config
NN708 Jun 28, 2020
f97f89f
docker: add docker-compose.yml
NN708 Jun 28, 2020
e27ce02
docker: pull from docker hub
NN708 Jun 28, 2020
a2ac7eb
docker: delete some ports in docker-compose.yml
NN708 Jun 28, 2020
0ca19c4
docker: add MySQL
NN708 Jun 28, 2020
2f76401
docker: downgrade MySQL to 5.7
NN708 Jun 30, 2020
4569957
docker: name containers
NN708 Jun 30, 2020
5814617
Merge branch 'next' into docker
shigma Aug 2, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# These are supported funding model platforms

github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom:
- https://afdian.net/@shigma
10 changes: 10 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM node:lts-alpine

EXPOSE 8080
VOLUME [ "/config" ]

WORKDIR /config
RUN npm i koishi -g
COPY ./start.js /utilities/start.js

CMD [ "node", "/utilities/start.js" ]
34 changes: 34 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
version: '2'

services:
cqhttp:
image: richardchien/cqhttp:latest
container_name: koishi_cqhttp
ports:
- 9000:9000 # VNC port
volumes:
- ./coolq:/home/user/coolq
environment:
VNC_PASSWD: MAX8char # change it
COOLQ_URL: http://dlsec.cqp.me/cqa-tuling # 'cqa-tuling' for CoolQ Air and 'cqp-tuling' for CoolQ Pro
CQHTTP_POST_URL: http://koishi:8080
CQHTTP_SERVE_DATA_FILES: "true"

mysql:
image: mysql:5.7
container_name: koishi_mysql
volumes:
- ./mysql:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: myPassword # change it
MYSQL_DATABASE: koishi
command: ['mysqld', '--character-set-server=utf8mb4', '--collation-server=utf8mb4_general_ci']

koishi:
image: koishijs/koishi:latest
container_name: koishi
volumes:
- ./koishi:/config
environment:
TYPE: http
SERVER: http://cqhttp:5700
32 changes: 32 additions & 0 deletions docker/start.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const fs = require('fs')
const child_process = require('child_process')

const path = process.cwd() + '/koishi.config.js'
if (!fs.existsSync(path)) {
let config = {
type: 'http',
port: 8080,
server: 'http://localhost:5700',
plugins: [
'common',
'schedule'
]
} // default config
const envNames = ['PORT', 'TYPE', 'SERVER']
envNames.map((name) => {
if (process.env[name]) config[name.toLowerCase()] = process.env[name]
})

output = JSON.stringify(config, null, 2)
output = 'module.exports = ' + output.replace(/^(\s+)"([\w$]+)":/mg, '$1$2:')
fs.writeFileSync(path, output)
console.log(`Successfully created config file: ${path}`)
}

console.log('Starting Koishi server...')
const koishi = child_process.exec('koishi run', (err) => {
if (err) throw err
})
process.stdin.pipe(koishi.stdin)
koishi.stdout.pipe(process.stdout)
console.log('Koishi server started.')
6 changes: 6 additions & 0 deletions packages/koishi-test-utils/src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ export const createMessageMeta = (type: ContextType, message: string, userId: nu
messageType: type === 'user' ? 'private' : type,
message,
userId,
sender: {
sex: 'unknown',
age: 0,
userId,
nickname: '' + userId,
},
})

export class Session {
Expand Down