├── .gitignore ├── run.sh ├── Dockerfile ├── config.template.json ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ -------------------------------------------------------------------------------- /run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [[ "$MODE" == "pub" ]]; then 4 | export PUBLISH_MODE=true 5 | export ROUTES=$(cat <<-END 6 | "pub": "/bitrix/pub/", 7 | "stat": "/server-stat/" 8 | END 9 | ) 10 | elif [[ "$MODE" == "sub" ]]; then 11 | export PUBLISH_MODE=false 12 | export ROUTES=$(cat <<-END 13 | "sub": "/bitrix/subws/" 14 | END 15 | ) 16 | fi 17 | 18 | envsubst /etc/push-server/config.json 19 | 20 | node server.js --config /etc/push-server/config.json -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM centos:7 as bitrixenv 2 | 3 | WORKDIR /build 4 | ADD build.sh /build 5 | RUN /build/build.sh 6 | 7 | FROM node:8-alpine 8 | 9 | EXPOSE 80 10 | 11 | WORKDIR /opt/push-server 12 | 13 | COPY --from=bitrixenv /opt/push-server /opt/push-server 14 | 15 | RUN set -x && \ 16 | apk add --update "libintl" && \ 17 | apk add --virtual build_deps "gettext" && \ 18 | cp /usr/bin/envsubst /usr/local/bin/envsubst && \ 19 | apk del build_deps 20 | 21 | ADD run.sh /opt/push-server 22 | ADD config.template.json /etc/push-server/ 23 | 24 | ENV LISTEN_PORT 8010 25 | ENV LISTEN_HOSTNAME 0.0.0.0 26 | ENV REDIS_HOST redis 27 | ENV REDIS_PORT 6379 28 | ENV SECURITY_KEY changeme 29 | ENV MODE pub 30 | 31 | ENTRYPOINT ["./run.sh"] -------------------------------------------------------------------------------- /config.template.json: -------------------------------------------------------------------------------- 1 | { 2 | "servers": [ 3 | { 4 | "name": "${MODE}-${LISTEN_PORT}", 5 | "port": ${LISTEN_PORT}, 6 | "hostname": "${LISTEN_HOSTNAME}", 7 | "backlog": 1024, 8 | "routes": {${ROUTES}} 9 | } 10 | ], 11 | "publishMode": ${PUBLISH_MODE}, 12 | "processUniqueId": "${MODE}-${LISTEN_PORT}", 13 | "clusterMode": true, 14 | "storage": { 15 | "type": "redis", 16 | "host": "${REDIS_HOST}", 17 | "port": "${REDIS_PORT}", 18 | "messageTLL": 86400, 19 | "channelTLL": 86400, 20 | "onlineTLL": 120, 21 | "onlineDelta": 10 22 | }, 23 | "security": { 24 | "key": "${SECURITY_KEY}" 25 | }, 26 | "debug": { 27 | "ip": ["127.0.0.1", "172.0.0.0/8"], 28 | "folderName": "/tmp" 29 | } 30 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Igor Karpovich 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # What is Bitrix Push Server 2 | 3 | Push Server is a NodeJS app built by [Bitrix Inc.](https://www.bitrix24.com) to handle realtime communications within Bitrix 4 | platform. It is usually installed as part of [Bitrix Environment](https://www.bitrix24.com/self-hosted/installation.php). 5 | 6 | # Use case for this Docker image 7 | 8 | If you'd like to run Bitrix24 in Docker on your own making realtime comms, i.e. chat and video calls to work is tricky. 9 | This image contains Bitrix Push Server from original Bitrix Environment package and can easily be placed into your existing project. 10 | The image is tested to work with *Docker Compose* and *Docker Swarm*. 11 | 12 | # How to use the image 13 | 14 | ## ... on its own 15 | 16 | You have to start [Redis](https://hub.docker.com/_/redis/) first. 17 | 18 | ```console 19 | $ docker run --name bitrix-push-server --link redis:redis -d ikarpovich/bitrix-push-server 20 | ``` 21 | 22 | ## ... in [`Docker Swarm`](https://docs.docker.com/engine/reference/commandline/stack_deploy/) or via [`Docker Compose`](https://github.com/docker/compose) 23 | 24 | The example below shows traefik installed in front of the cluster 25 | 26 | ```yaml 27 | version: '3' 28 | 29 | services: 30 | 31 | push-server-sub: 32 | image: ikarpovich/bitrix-push-server 33 | links: 34 | - redis 35 | networks: 36 | - default 37 | - traefik-net 38 | environment: 39 | - REDIS_HOST=redis 40 | - LISTEN_HOSTNAME=0.0.0.0 41 | - LISTEN_PORT=80 42 | - SECURITY_KEY=testtesttest 43 | - MODE=sub 44 | labels: 45 | - traefik.port=80 46 | - traefik.protocol=http 47 | - traefik.frontend.rule=Host:bitrix24-sub.test 48 | - traefik.docker.network=traefik-net 49 | 50 | push-server-pub: 51 | image: ikarpovich/bitrix-push-server 52 | links: 53 | - redis 54 | networks: 55 | - default 56 | environment: 57 | - REDIS_HOST=redis 58 | - LISTEN_HOSTNAME=0.0.0.0 59 | - LISTEN_PORT=80 60 | - SECURITY_KEY=testtesttest 61 | - MODE=pub 62 | 63 | redis: 64 | image: redis 65 | networks: 66 | - default 67 | ``` 68 | 69 | ## Setup your Bitrix to support the server: 70 | 71 | Message sender path: `http://push-server-pub/bitrix/pub/` 72 | Signature code for server interaction: `testtesttest` (your `SECURITY_KEY`) 73 | 74 | Message listener path: `http://bitrix24-sub.test/bitrix/subws/` (https:// ws:// wss://) 75 | 76 | # Environment variables 77 | 78 | ### `LISTEN_HOSTNAME` 79 | 80 | Hostname to bind daemon to, `0.0.0.0` by default 81 | 82 | ### `LISTEN_PORT` 83 | 84 | Port to bind daemon to, `80` by default 85 | 86 | ### `REDIS_HOST` 87 | 88 | Redis hostname, `redis` by default 89 | 90 | ### `REDIS_PORT` 91 | 92 | Redis port, `6379` by default 93 | 94 | ### `SECURITY_KEY` 95 | 96 | Security key, has to match one in *Push & Pull* system module settings 97 | 98 | ### `MODE` 99 | 100 | Mode should be either `pub` or `sub`. You have to launch two containers with each mode to work. 101 | 102 | # License 103 | 104 | License for this image is MIT. 105 | Bitrix and Bitrix Environment, Bitri Push Server are products licensed by Bitrix Inc. under their license terms. --------------------------------------------------------------------------------