-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closed
Description
UPDATE 4th Nov 2016
All done. Please goto wiki: Docker
The Problem
to setup running environment for wechaty is not easy for everyone. sometimes even myself have trouble with that.
A Solution
so it must be fully dockerized! after dockerize, we can use wechaty like the following:
$ cat > mybot.ts
// have to use absolute path `'/wechaty'` to make `ts-node` happy. will fix it later.
// import Wechaty from '/wechaty'
import { Wechaty } from 'wechaty' // just from 'wechaty' is OK
const bot = Wechaty.instance()
console.log(bot.version())
^D
$ alias wechaty='docker run \
-t -i --rm \
-e WECHATY_LOG="$WECHATY_LOG" \
--volume="$(pwd)":/bot \
--name=wechaty \
zixia/wechaty \
'
$ wechaty mybot.ts
see? death easy to use!
Docker options explanation
-t
: Allocate a pseudo-TTY-i
: Keep STDIN open even if not attached--rm
: Automatically remove the container when it exits-e WECHATY_LOG="$WECHATY_LOG"
: Pass the environment variableWECHATY_LOG
into the container--volume="$(pwd)":/bot
: Bind current directory(replaced by"$(pwd)"
) to '/bot
' inside the container, by mounting the volume--name=wechaty
: Assignwechaty
as the container namezixia/wechaty
: Image name on docker hub, here's our zixia/wechatymybot.ts
: File contains code wrote by you, should be placed in current directory./
Reference
- chromium require libgconf-2-4 package: Linux: ./electron: error while loading shared libraries: libgconf-2.so.4 electron/electron#1518
- Microcontainers – Tiny, Portable Docker Containers
Memo
this issue will record the process of Wechaty Docker and will be used for reference from other issues related.
huan and lijiarui