forked from wechaty/wechaty
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/Chatie/wechaty
- Loading branch information
Showing
49 changed files
with
1,076 additions
and
1,064 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,7 @@ | ||
sudo: required | ||
dist: trusty | ||
language: node_js | ||
|
||
node_js: | ||
- "7" | ||
- "8" | ||
- "9" | ||
|
||
os: | ||
- linux | ||
|
@@ -22,22 +19,45 @@ cache: | |
- node_modules | ||
|
||
before_install: | ||
|
||
install: | ||
- if [ "$TRAVIS_OS_NAME" == 'osx' ]; then brew update; brew cleanup; brew cask cleanup; fi | ||
- if [ "$TRAVIS_OS_NAME" == 'osx' ]; then brew uninstall --force brew-cask; brew update; fi | ||
- if [ "$TRAVIS_OS_NAME" == 'osx' ]; then brew update; fi | ||
- if [ "$TRAVIS_OS_NAME" == 'osx' ]; then brew cleanup; fi | ||
- if [ "$TRAVIS_OS_NAME" == 'osx' ]; then brew cask cleanup; fi | ||
- if [ "$TRAVIS_OS_NAME" == 'osx' ]; then brew install jq; fi | ||
- if [ "$TRAVIS_OS_NAME" == 'osx' ]; then brew install moreutils; fi | ||
- if [ "$TRAVIS_OS_NAME" == 'osx' ]; then brew install shellcheck; fi | ||
- if [ "$TRAVIS_OS_NAME" == 'osx' ]; then brew install jq; fi | ||
- npm install | ||
|
||
script: | ||
- echo $TRAVIS_OS_NAME | ||
- node --version | ||
- npm --version | ||
- shellcheck bin/*.sh | ||
- npm run test:linux | ||
- npm run test:npm && echo 'Npm packing test is passed' | ||
- n=0; npm test; while ((n < 3 && $? > 0)); do ((n++)); npm test; done | ||
|
||
after_success: | ||
- if [ "$TRAVIS_OS_NAME" == 'osx' ]; then npm run coverage; fi | ||
|
||
stages: | ||
- test | ||
- pack | ||
- name: deploy | ||
if: branch =~ ^(master|v\d+\.\d+) | ||
|
||
jobs: | ||
include: | ||
- stage: pack | ||
script: | ||
- npm run test:pack && echo 'Npm packing test is passed' | ||
|
||
- stage: deploy | ||
script: | ||
- echo "Deploying to NPM ..." | ||
- npm version | ||
- npm run dist | ||
|
||
deploy: | ||
provider: npm | ||
email: [email protected] | ||
api_key: "$NPM_TOKEN" | ||
skip_cleanup: true | ||
|
||
notifications: | ||
webhooks: | ||
|
@@ -49,16 +69,3 @@ notifications: | |
email: | ||
on_success: change | ||
on_failure: change | ||
|
||
after_success: | ||
- if [ "$TRAVIS_OS_NAME" == 'osx' ]; then npm run coverage; fi | ||
|
||
before_deploy: | ||
- npm version | ||
- npm run dist | ||
|
||
deploy: | ||
provider: npm | ||
email: [email protected] | ||
api_key: "$NPM_TOKEN" | ||
skip_cleanup: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
Huan <[email protected]> https://github.com/zixia | ||
|
||
Rui <[email protected]> https://github.com/lijiarui |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,80 @@ | ||
FROM node:7 | ||
FROM ubuntu:17.10 | ||
LABEL maintainer="Huan LI <[email protected]>" | ||
|
||
ENV NPM_CONFIG_LOGLEVEL warn | ||
ENV DEBIAN_FRONTEND noninteractive | ||
ENV WECHATY_DOCKER 1 | ||
ENV LC_ALL C.UTF-8 | ||
ENV NODE_ENV $NODE_ENV | ||
ENV NPM_CONFIG_LOGLEVEL warn | ||
|
||
# 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 \ | ||
build-essential \ | ||
ca-certificates \ | ||
curl \ | ||
coreutils \ | ||
figlet \ | ||
git \ | ||
jq \ | ||
libav-tools \ | ||
libgconf-2-4 \ | ||
moreutils \ | ||
shellcheck \ | ||
sudo \ | ||
ttf-freefont \ | ||
tzdata \ | ||
vim \ | ||
wget \ | ||
&& apt-get purge --auto-remove \ | ||
&& rm -rf /tmp/* /var/lib/apt/lists/* | ||
|
||
RUN curl -sL https://deb.nodesource.com/setup_9.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/* | ||
|
||
# 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. | ||
RUN apt-get update && apt-get install -y wget --no-install-recommends \ | ||
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \ | ||
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \ | ||
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \ | ||
&& apt-get update \ | ||
&& apt-get install -y google-chrome-unstable \ | ||
--no-install-recommends \ | ||
&& rm -rf /var/lib/apt/lists/* \ | ||
&& apt-get update && apt-get install -y --no-install-recommends \ | ||
google-chrome-unstable \ | ||
&& apt-get purge --auto-remove \ | ||
&& rm -rf /src/*.deb | ||
|
||
# Add chatie user. | ||
RUN groupadd -r bot && useradd -r -g bot -d /bot -m -G audio,video,sudo bot \ | ||
&& mkdir -p /bot/Downloads \ | ||
&& chown -R bot:bot /bot \ | ||
&& echo "bot ALL=NOPASSWD:ALL" >> /etc/sudoers | ||
&& rm -rf /tmp/* /var/lib/apt/lists/* \ | ||
&& rm -rf /usr/bin/google-chrome* /opt/google/chrome-unstable | ||
|
||
RUN mkdir /wechaty \ | ||
&& chown -R bot:bot /wechaty \ | ||
&& mkdir /node_modules | ||
|
||
WORKDIR /wechaty | ||
VOLUME [ "/bot" ] | ||
|
||
# Run user as non privileged. | ||
USER bot | ||
|
||
COPY package.json . | ||
RUN npm install \ | ||
RUN npm install \ | ||
&& sudo rm -fr /tmp/* ~/.npm | ||
|
||
COPY . . | ||
RUN npm run dist | ||
RUN npm run test \ | ||
&& npm run dist | ||
|
||
# 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 sudo npm link \ | ||
RUN sudo mkdir /bot \ | ||
&& npm link \ | ||
&& sudo ln -s /wechaty /node_modules/wechaty \ | ||
&& sudo ln -s /wechaty/node_modules/* /node_modules/ \ | ||
&& sudo ln -s /wechaty/node_modules/.bin/* /usr/local/bin/ \ | ||
&& sudo ln -s /wechaty/tsconfig.json / \ | ||
&& echo "export * from 'wechaty'" | sudo tee /index.ts \ | ||
&& echo 'Linked wechaty to global' | ||
&& echo 'Linked Wechaty to Global' | ||
|
||
ENTRYPOINT [ "/wechaty/bin/entrypoint.sh" ] | ||
CMD [ "" ] | ||
ENTRYPOINT [ "/wechaty/bin/entrypoint.sh" ] | ||
CMD [ "" ] | ||
|
||
# | ||
# https://docs.docker.com/docker-cloud/builds/advanced/ | ||
|
@@ -83,12 +88,11 @@ LABEL org.label-schema.license="Apache-2.0" \ | |
org.label-schema.description="Wechat for Bot" \ | ||
org.label-schema.usage="https://github.com/chatie/wechaty/wiki/Docker" \ | ||
org.label-schema.url="https://www.chatie.io" \ | ||
org.label-schema.vendor="AKA Mobi" \ | ||
org.label-schema.vendor="Chatie" \ | ||
org.label-schema.vcs-ref="$SOURCE_COMMIT" \ | ||
org.label-schema.vcs-url="https://github.com/chatie/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" | ||
org.label-schema.docker.params="WECHATY_TOKEN=token token from https://www.chatie.io, WECHATY_LOG=verbose Set Verbose Log, TZ='Asia/Shanghai' TimeZone" | ||
|
||
#RUN npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
FROM zixia/wechaty | ||
|
||
RUN sudo mkdir /app/ \ | ||
&& sudo chown -R bot:bot /app/ | ||
WORKDIR /app/ | ||
|
||
ONBUILD ARG NODE_ENV | ||
ONBUILD ENV NODE_ENV $NODE_ENV | ||
|
||
ONBUILD WORKDIR /bot | ||
|
||
ONBUILD COPY package.json . | ||
ONBUILD RUN npm install && npm cache clean && rm -fr /tmp/* ~/.npm | ||
ONBUILD RUN sudo chown bot package.json \ | ||
&& jq 'del(.dependencies.wechaty)' package.json | sponge package.json \ | ||
&& npm install \ | ||
&& sudo rm -fr /tmp/* ~/.npm | ||
ONBUILD COPY . . | ||
|
||
CMD [ "npm", "start" ] |
Oops, something went wrong.