This commit is contained in:
2026-05-20 15:23:05 +03:00
commit 43c0739dfa
703 changed files with 61692 additions and 0 deletions
+49
View File
@@ -0,0 +1,49 @@
FROM node:22-trixie AS builder
USER root
ENV PUSH=push-server.tar.gz
RUN mkdir -p /opt/push-server
COPY push-server-0.5.0.tar.gz /opt/push-server/$PUSH
WORKDIR /opt/push-server
RUN tar xzvvf $PUSH && rm -f $PUSH
RUN npm install --omit=dev
FROM node:22-alpine AS production
USER root
RUN apk --no-cache add shadow bash gettext libintl curl openssl ca-certificates tzdata && \
addgroup -g 979 bitrix && \
adduser -D -u 979 -G bitrix bitrix && \
mkdir -p /usr/local/bin && \
mv /usr/bin/envsubst /usr/local/bin/envsubst && \
[[ ! -d /tmp/push-server ]] && mkdir /tmp/push-server && \
[[ ! -d /etc/push-server ]] && mkdir /etc/push-server && \
mkdir -p /var/log/push-server && \
ln -sf /dev/stdout /var/log/push-server/info.log && \
ln -sf /dev/stderr /var/log/push-server/error.log
WORKDIR /opt/push-server
COPY --from=builder /opt/push-server /opt/push-server
COPY docker-entrypoint.sh /usr/local/bin/
COPY push-server-pub.json /etc/push-server/push-server-pub.json
COPY push-server-sub.json /etc/push-server/push-server-sub.json
RUN chown -R bitrix:bitrix /opt/push-server && \
chown -R bitrix:bitrix /tmp/push-server && \
chown -R bitrix:bitrix /etc/push-server && \
chmod 0755 /usr/local/bin/docker-entrypoint.sh && \
chown -R bitrix:bitrix /var/log/push-server
# VOLUME /var/log/push-server
USER bitrix:bitrix
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
+71
View File
@@ -0,0 +1,71 @@
#!/bin/bash
#
# Push Server on NodeJS variables
#
# REDIS_HOST - redis host
# REDIS_PORT - redis port
#
# PUSH_SECURITY_KEY - push security key
# PUSH_PUB_MODE - push pub
# PUSH_PUB_PORT - push pub port
# PUSH_SUB_MODE - push sub
# PUSH_SUB_PORT - push sub port
#
# RUN_DIR - temporary directory for service; default /tmp/push-server
# PUB_URI - pub service uri
# REST_URI - rest service uri
# SUB_URI - sub service uri
#
export WORKDIR=/opt/push-server
export CONFIG_DIR=/etc/push-server
PUB_TMPL=$CONFIG_DIR/push-server-pub.json
SUB_TMPL=$CONFIG_DIR/push-server-sub.json
CONFIG=$CONFIG_DIR/config.json
export LOG_DIR=/var/log/push-server
[[ -z $RUN_DIR ]] && RUN_DIR=/tmp/push-server
export RUN_DIR
#
log() {
msg="${1}"
printf "%-16s: [%d]> %s\n" "$(date +%Y/%m/%dT%H:%M)" "$$" "$msg"
}
#
error() {
msg="${1}"
rtn="${2:-1}"
log "$msg"
exit $rtn
}
#
pushd $WORKDIR || error "Cannot access $WORKDIR"
[[ -z $PUSH_PUB_MODE && -z $PUSH_SUB_MODE ]] && error "Not defind push-server mode environment variables: PUSH_PUB_MODE or PUSH_SUB_MODE"
[[ $PUSH_PUB_MODE != "pub" && -z $PUSH_SUB_MODE ]] && error "Incorrect value in PUSH_PUB_MODE=$PUSH_PUB_MODE variable"
[[ -z $PUSH_PUB_MODE && $PUSH_SUB_MODE != "sub" ]] && error "Incorrect value in PUSH_SUB_MODE=$PUSH_SUB_MODE variable"
#
if [[ $PUSH_PUB_MODE == "pub" ]];
then
log "PUSH_PUB_MODE=$PUSH_PUB_MODE"
TEMPLATE=$PUB_TMPL
[[ -z $REST_URI ]] && REST_URI="/bitrix/rest/"
[[ -z $PUB_URI ]] && PUB_URI="/bitrix/pub/"
log "REST_URI=$REST_URI"
log "PUB_URI=$PUB_URI"
export REST_URI
export PUB_URI
elif [[ $PUSH_SUB_MODE == "sub" ]];
then
log "PUSH_SUB_MODE=$PUSH_SUB_MODE"
TEMPLATE=$SUB_TMPL
[[ -z $SUB_URI ]] && SUB_URI="/bitrix/subws/"
log "SUB_URI=$SUB_URI"
export SUB_URI
fi
#
popd
#
log "Create $CONFIG"
envsubst <$TEMPLATE >$CONFIG
#
log "Start server"
node server.js --config $CONFIG
#
Binary file not shown.
+50
View File
@@ -0,0 +1,50 @@
{
"servers":
[
{
"name": "${PUSH_PUB_MODE}-${PUSH_PUB_PORT}",
"port": ${PUSH_PUB_PORT},
"hostname": "0.0.0.0",
"backlog": 1024,
"routes":
{
"pub": "${PUB_URI}",
"stat": "/server-stat/",
"rest": "${REST_URI}"
}
}
],
"publishMode": true,
"dataDir": "${WORKDIR}/data",
"processUniqueId": "${PUSH_PUB_MODE}-${PUSH_PUB_PORT}",
"clusterMode": true,
"storage":
{
"type": "redis",
"messageTLL": 86400,
"channelTLL": 86400,
"onlineTLL": 120,
"onlineDelta": 10,
"host": "${REDIS_HOST}",
"port": ${REDIS_PORT}
},
"security":
{
"key": "${PUSH_SECURITY_KEY}"
},
"limits":
{
"maxPayload": 1048576,
"maxConnPerChannel": 100,
"maxMessagesPerRequest": 100,
"maxChannelsPerRequest": 100,
"maxRequestsPerSecond": 50
},
"debug":
{
"folderName": "/var/log/push-server",
"ip": ["127.0.0.256"],
"trustProxy": true,
"combineLogs": true
}
}
+39
View File
@@ -0,0 +1,39 @@
{
"servers":
[
{
"name": "${PUSH_SUB_MODE}-${PUSH_SUB_PORT}",
"port": ${PUSH_SUB_PORT},
"hostname": "0.0.0.0",
"backlog": 1024,
"routes":
{
"sub": "${SUB_URI}"
}
}
],
"dataDir": "${WORKDIR}/data",
"clusterMode": true,
"processUniqueId": "${PUSH_SUB_MODE}-${PUSH_SUB_PORT}",
"storage":
{
"type": "redis",
"messageTLL": 86400,
"channelTLL": 86400,
"onlineTLL": 120,
"onlineDelta": 10,
"host": "${REDIS_HOST}",
"port": ${REDIS_PORT}
},
"security":
{
"key": "${PUSH_SECURITY_KEY}"
},
"debug":
{
"folderName": "/var/log/push-server",
"ip": ["127.0.0.256"],
"trustProxy": true,
"combineLogs": true
}
}