Dockerfile 3.7 KB
Newer Older
1
FROM ubuntu:18.04
2 3 4
LABEL maintainer="Huan LI <zixia@zixia.net>"

ENV DEBIAN_FRONTEND     noninteractive
5
ENV WECHATY_DOCKER      1
Huan (李卓桓)'s avatar
Huan (李卓桓) 已提交
6 7 8
ENV LC_ALL              C.UTF-8
ENV NODE_ENV            $NODE_ENV
ENV NPM_CONFIG_LOGLEVEL warn
9 10 11 12 13 14 15

# Installing the 'apt-utils' package gets rid of the 'debconf: delaying package configuration, since apt-utils is not installed'
# error message when installing any other package with the apt-get package manager.
# https://peteris.rocks/blog/quiet-and-unattended-installation-with-apt-get/
RUN apt-get update && apt-get install -y --no-install-recommends \
    apt-utils \
    bash \
Huan (李卓桓)'s avatar
Huan (李卓桓) 已提交
16
    build-essential \
17 18 19
    ca-certificates \
    curl \
    coreutils \
20
    ffmpeg \
21
    figlet \
Huan (李卓桓)'s avatar
Huan (李卓桓) 已提交
22
    git \
23
    gnupg2 \
24
    jq \
Huan (李卓桓)'s avatar
Huan (李卓桓) 已提交
25
    libgconf-2-4 \
26
    moreutils \
27
    python-dev \
28
    shellcheck \
29
    sudo \
30
    tzdata \
31
    vim \
Huan (李卓桓)'s avatar
Huan (李卓桓) 已提交
32
    wget \
33 34
  && apt-get purge --auto-remove \
  && rm -rf /tmp/* /var/lib/apt/lists/*
35

36
RUN curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - \
37
    && apt-get update && apt-get install -y --no-install-recommends nodejs \
38 39
    && apt-get purge --auto-remove \
    && rm -rf /tmp/* /var/lib/apt/lists/*
40 41 42 43 44

# https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md
# https://github.com/ebidel/try-puppeteer/blob/master/backend/Dockerfile
# Install latest chrome dev package.
# Note: this also installs the necessary libs so we don't need the previous RUN command.
Huan (李卓桓)'s avatar
Huan (李卓桓) 已提交
45
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
46
    && sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
Huan (李卓桓)'s avatar
Huan (李卓桓) 已提交
47 48
    && apt-get update && apt-get install -y --no-install-recommends \
      google-chrome-unstable \
Huan (李卓桓)'s avatar
Huan (李卓桓) 已提交
49
    && apt-get purge --auto-remove \
50 51
    && rm -rf /tmp/* /var/lib/apt/lists/* \
    && rm -rf /usr/bin/google-chrome* /opt/google/chrome-unstable
52

53
RUN mkdir /wechaty /node_modules
Huan (李卓桓)'s avatar
Huan (李卓桓) 已提交
54
WORKDIR   /wechaty
55

Huan (李卓桓)'s avatar
Huan (李卓桓) 已提交
56
COPY package.json .
57
RUN npm install \
58
  && npm run puppet-install \
59
  && sudo rm -fr /tmp/* ~/.npm
60

61
COPY . .
62
# RUN npm run test:debug
63
RUN npm test
64
RUN npm run dist
65

66 67
# 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.
Huan (李卓桓)'s avatar
Huan (李卓桓) 已提交
68 69
RUN sudo mkdir /bot \
    && npm link \
70 71 72
    && sudo ln -sfv /usr/lib/node_modules/* /node_modules/ \
    && sudo ln -sfv /wechaty/node_modules/* /node_modules/ \
    && sudo ln -sfv /wechaty/tsconfig.json / \
73
    && echo 'Linked Wechaty to Global'
74

75 76
ENTRYPOINT  [ "/wechaty/bin/entrypoint.sh" ]
CMD         [ "" ]
77

78 79 80 81
#
# https://docs.docker.com/docker-cloud/builds/advanced/
# http://label-schema.org/rc1/
#
82
LABEL org.label-schema.license="Apache-2.0" \
83 84 85 86 87
      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" \
88
      org.label-schema.usage="https://github.com/chatie/wechaty/wiki/Docker" \
89
      org.label-schema.url="https://www.chatie.io" \
Huan (李卓桓)'s avatar
Huan (李卓桓) 已提交
90
      org.label-schema.vendor="Chatie" \
91
      org.label-schema.vcs-ref="$SOURCE_COMMIT" \
92
      org.label-schema.vcs-url="https://github.com/chatie/wechaty" \
93 94 95
      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" \
96
      org.label-schema.docker.params="WECHATY_TOKEN=token token from https://www.chatie.io, WECHATY_LOG=verbose Set Verbose Log, TZ='Asia/Shanghai' TimeZone"
97