Dockerfile 2.7 KB
Newer Older
1 2
#
# Wechaty Docker
3
# https://github.com/chatie/wechaty
4
#
5 6 7 8
# FROM alpine
#
# Docker image for Alpine Linux with latest ShellCheck, a static analysis tool for shell scripts.
# https://hub.docker.com/r/nlknguyen/alpine-shellcheck/
9 10
# FROM nlknguyen/alpine-shellcheck
FROM mhart/alpine-node:7
Huan (李卓桓)'s avatar
Huan (李卓桓) 已提交
11
MAINTAINER Huan LI <zixia@zixia.net>
12 13

RUN  apk update && apk upgrade \
14
  && apk add \
15 16 17
      bash \
      ca-certificates \
      chromium-chromedriver \
Huan (李卓桓)'s avatar
Huan (李卓桓) 已提交
18
      chromium \
19
      coreutils \
20
      ffmpeg \
Huan (李卓桓)'s avatar
Huan (李卓桓) 已提交
21
      figlet \
22
      jq \
Huan (李卓桓)'s avatar
fix 235  
Huan (李卓桓) 已提交
23
      ttf-freefont \
24
      udev \
Huan (李卓桓)'s avatar
Huan (李卓桓) 已提交
25
      vim \
26
      xauth \
Huan (李卓桓)'s avatar
Huan (李卓桓) 已提交
27
      xvfb \
28
  && rm -rf /tmp/* /var/cache/apk/*
29

Huan (李卓桓)'s avatar
Huan (李卓桓) 已提交
30
RUN mkdir /wechaty
31
WORKDIR /wechaty
Huan (李卓桓)'s avatar
Huan (李卓桓) 已提交
32

33 34
# npm `chromedriver` not support alpine linux
# https://github.com/giggio/node-chromedriver/issues/70
Huan (李卓桓)'s avatar
Huan (李卓桓) 已提交
35
COPY package.json .
36
RUN  sed -i '/chromedriver/d' package.json \
37
  && npm --silent --progress=false install > /dev/null \
38
  && npm --silent --progress=false install phantomjs-prebuilt > /dev/null \
39
  && rm -fr /tmp/* ~/.npm
40

41 42
# Loading from node_modules Folders: https://nodejs.org/api/modules.html
# If it is not found there, then it moves to the parent directory, and so on, until the root of the file system is reached.
43 44
COPY . .
RUN  sed -i '/chromedriver/d' package.json \
45
  && npm run dist \
46
  && npm --silent --progress=false link \
47 48
  \
  && mkdir /bot \
49 50 51
  \
  && (   mkdir /node_modules && cd /node_modules \
      && ln -s /wechaty . \
52
      && ln -s /wechaty/node_modules/* . \
53
    ) \
54
  && ln -s /wechaty/tsconfig.json / \
Huan (李卓桓)'s avatar
Huan (李卓桓) 已提交
55
  && echo "export * from 'wechaty'" > /index.ts \
56 57
  \
  && echo 'Linked wechaty to global'
58

59
VOLUME [ "/bot" ]
60

61
ENTRYPOINT [ "/wechaty/bin/entrypoint.sh" ]
Huan (李卓桓)'s avatar
Huan (李卓桓) 已提交
62
CMD [ "" ]
63

64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
#
# https://docs.docker.com/docker-cloud/builds/advanced/
# http://label-schema.org/rc1/
#
LABEL org.label-schema.license="ISC" \
      org.label-schema.build-date="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \
      org.label-schema.version="$DOCKER_TAG" \
      org.label-schema.schema-version="$(wechaty-version)" \
      org.label-schema.name="Wechaty" \
      org.label-schema.description="Wechat for Bot" \
      org.label-schema.usage="https://github.com/wechaty/wechaty/wiki/Docker" \
      org.label-schema.url="https://www.chatie.io" \
      org.label-schema.vendor="AKA Mobi" \
      org.label-schema.vcs-ref="$SOURCE_COMMIT" \
      org.label-schema.vcs-url="https://github.com/wechaty/wechaty" \
      org.label-schema.docker.cmd="docker run -ti --rm zixia/wechaty <code.js>" \
      org.label-schema.docker.cmd.test="docker run -ti --rm zixia/wechaty test" \
      org.label-schema.docker.cmd.help="docker run -ti --rm zixia/wechaty help" \
      org.label-schema.docker.params="WECHATY_TOKEN=token token from https://www.chatie.io"
83

84
#RUN npm test