-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
Dockerfile
104 lines (90 loc) · 3.23 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
FROM debian:bullseye
LABEL maintainer="Huan LI (李卓桓) <zixia@zixia.net>"
ENV DEBIAN_FRONTEND noninteractive
ENV WECHATY_DOCKER 1
ENV LC_ALL C.UTF-8
ENV NODE_ENV $NODE_ENV
ENV NPM_CONFIG_LOGLEVEL warn
# Instal the 'apt-utils' package to solve the error 'debconf: delaying package configuration, since apt-utils is not installed'
# https://peteris.rocks/blog/quiet-and-unattended-installation-with-apt-get/
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
apt-utils \
autoconf \
automake \
bash \
build-essential \
ca-certificates \
chromium \
coreutils \
curl \
ffmpeg \
figlet \
git \
gnupg2 \
jq \
libgconf-2-4 \
libtool \
libxtst6 \
moreutils \
python-dev \
shellcheck \
sudo \
tzdata \
vim \
wget \
&& apt-get purge --auto-remove \
&& rm -rf /tmp/* /var/lib/apt/lists/*
RUN curl -sL https://deb.nodesource.com/setup_16.x | bash - \
&& apt-get update && apt-get install -y --no-install-recommends nodejs \
&& apt-get purge --auto-remove \
&& rm -rf /tmp/* /var/lib/apt/lists/*
WORKDIR /wechaty
COPY package.json .
RUN npm install \
&& rm -fr /tmp/* ~/.npm
COPY . .
RUN ./scripts/generate-package-json.sh && rm -f src/package-json.spec.ts
RUN npm test \
&& npm run dist \
&& npm link
# Pre-install all puppets.
# Must be placed after `npm link`, or it will be all deleted by `npm link`
RUN npm run puppet-install \
&& sudo rm -fr /tmp/* ~/.npm
#
# Enable ES Modules support #2232
# See: https://github.com/wechaty/wechaty/issues/2232
#
RUN echo '{"type": "module"}' > /package.json
# 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.
RUN mkdir /node_modules \
&& ln -sfv /usr/lib/node_modules/* /node_modules/ \
&& ln -sfv /wechaty/node_modules/* /node_modules/ \
&& /wechaty/bin/clean-json.js /wechaty/tsconfig.json \
| jq 'del(."ts-node")' > /tsconfig.json \
&& echo 'Linked Wechaty & tsconfig.json to Global'
WORKDIR /bot
ENTRYPOINT [ "/wechaty/bin/entrypoint.sh" ]
CMD [ "" ]
#
# https://docs.docker.com/docker-cloud/builds/advanced/
# http://label-schema.org/rc1/
#
LABEL \
org.label-schema.license="Apache-2.0" \
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="Chatie" \
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 wechaty/wechaty <code.js>" \
org.label-schema.docker.cmd.test="docker run -ti --rm wechaty/wechaty test" \
org.label-schema.docker.cmd.help="docker run -ti --rm wechaty/wechaty help" \
org.label-schema.docker.params="WECHATY_TOKEN=token token from https://www.chatie.io, WECHATY_LOG=verbose Set Verbose Log, TZ='Asia/Shanghai' TimeZone"