Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change entrypoint script to python #111

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ RUN yum -y updateinfo && \
yum clean all && \
rm -f /var/log/*log
COPY --chown=ds:ds config/nginx/nginx.conf /etc/nginx/nginx.conf
COPY --chown=ds:ds proxy-docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
COPY --chown=ds:ds proxy-docker-entrypoint.py /docker-entrypoint.py
COPY --chown=ds:ds --chmod=644 --from=ds-service \
/etc/$COMPANY_NAME/documentserver/nginx/ds.conf \
/etc/nginx/conf.d/
Expand Down Expand Up @@ -130,7 +130,7 @@ RUN sed 's|\(application\/zip.*\)|\1\n application\/wasm wasm;|' \
-exec sh -c 'gzip -cf9 $0 > $0.gz && chown ds:ds $0.gz' {} \;
VOLUME /var/lib/$COMPANY_NAME
USER ds
ENTRYPOINT docker-entrypoint.sh
ENTRYPOINT ["python", "/docker-entrypoint.py"]

FROM ds-base AS docservice
EXPOSE 8000
Expand Down Expand Up @@ -159,9 +159,9 @@ COPY --chown=ds:ds --from=ds-service \
COPY --from=ds-service \
/var/www/$COMPANY_NAME/documentserver/document-templates/new \
/var/www/$COMPANY_NAME/documentserver/document-templates/new
COPY docker-entrypoint.sh /usr/local/bin/
COPY docker-entrypoint.py /
USER ds
ENTRYPOINT docker-entrypoint.sh /var/www/$COMPANY_NAME/documentserver/server/DocService/docservice
ENTRYPOINT ["python", "/docker-entrypoint.py", "/var/www/$COMPANY_NAME/documentserver/server/DocService/docservice"]
HEALTHCHECK --interval=10s --timeout=3s CMD curl -sf http://localhost:8000/index.html

FROM ds-base AS converter
Expand Down Expand Up @@ -196,13 +196,13 @@ COPY --from=ds-service \
COPY --from=ds-service \
/ds/usr/lib64/* \
/usr/lib64/
COPY docker-entrypoint.sh /usr/local/bin/
COPY docker-entrypoint.py /
RUN mkdir -p \
/var/lib/$COMPANY_NAME/documentserver/App_Data/cache/files \
/var/lib/$COMPANY_NAME/documentserver/App_Data/docbuilder && \
chown -R ds:ds /var/lib/$COMPANY_NAME/documentserver
USER ds
ENTRYPOINT docker-entrypoint.sh /var/www/$COMPANY_NAME/documentserver/server/FileConverter/converter
ENTRYPOINT ["python", "/docker-entrypoint.py", "/var/www/$COMPANY_NAME/documentserver/server/FileConverter/converter"]

FROM node:lts-buster-slim AS example
LABEL maintainer Ascensio System SIA <support@onlyoffice.com>
Expand Down
173 changes: 173 additions & 0 deletions docker-entrypoint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
import os, json, sys
LOG_LEVEL = os.environ.get("LOG_LEVEL")
LOG_TYPE = os.environ.get("LOG_TYPE")
LOG_PATTERN = os.environ.get("LOG_PATTERN")
COMPANY_NAME = os.environ.get("COMPANY_NAME", "onlyoffice")
REDIS_SERVER_USER = os.environ.get("REDIS_SERVER_USER", "default")
REDIS_SERVER_PWD = os.environ.get("REDIS_SERVER_PWD", "")
REDIS_CLUSTER = os.environ.get("REDIS_CLUSTER")
REDIS_CLUSTER_NODES = os.environ.get("REDIS_CLUSTER_NODES")
REDIS_SENTINEL_GROUP_NAME = os.environ.get("REDIS_SENTINEL_GROUP_NAME", "mymaster")
REDIS_CONNECTOR_NAME = os.environ.get("REDIS_CONNECTOR_NAME", "redis")
AMQP_TYPE = os.environ.get("AMQP_TYPE", "rabbitmq")
AMQP_PORT = os.environ.get("AMQP_PORT", "5672")
AMQP_HOST = os.environ.get("AMQP_HOST", "localhost")
AMQP_USER = os.environ.get("AMQP_USER", "guest")
AMQP_PWD = os.environ.get("AMQP_PWD", "guest")
ACTIVEMQ_TRANSPORT = os.environ.get("ACTIVEMQ_TRANSPORT")
AMQP_PROTO = os.environ.get("AMQP_PROTO", "amqp")
AMQP_VHOST = os.environ.get("AMQP_VHOST", "/")
AMQP_URI = os.environ.get("AMQP_URI", AMQP_PROTO + "://" + AMQP_USER + ":" + AMQP_PWD + "@" + AMQP_HOST + ":" + AMQP_PORT + AMQP_VHOST)

if LOG_LEVEL or LOG_TYPE or LOG_PATTERN:
filePath = "/etc/{0}/documentserver/log4js/production.json".format(COMPANY_NAME)
with open(filePath, 'r') as json_file:
logConfig = json.load(json_file)
if LOG_LEVEL:
logConfig["categories"]["default"]["level"] = LOG_LEVEL
if LOG_TYPE:
logConfig["appenders"]["default"]["layout"]["type"] = LOG_TYPE
if LOG_PATTERN:
logConfig["appenders"]["default"]["layout"]["pattern"] = LOG_PATTERN
with open(filePath, "w") as json_file:
json.dump(logConfig, json_file, indent=4)

if REDIS_CLUSTER_NODES:
lst = REDIS_CLUSTER_NODES.split()
nodes = []
for i in lst:
nodes.append({ "url": "redis://" + i })
redisConfig = {"optionsCluster": {"rootNodes": nodes, "defaults": { "username": REDIS_SERVER_USER, "password": REDIS_SERVER_PWD }}}
elif REDIS_CONNECTOR_NAME == "ioredis":
redisConfig = {
"iooptions": {
"sentinels": [
{
"host": os.environ.get("REDIS_SERVER_HOST", "localhost"),
"port": os.environ.get("REDIS_SERVER_PORT", "6379")
}
],
"name": REDIS_SENTINEL_GROUP_NAME,
"username": REDIS_SERVER_USER,
"password": REDIS_SERVER_PWD,
"db": os.environ.get("REDIS_SERVER_DB_NUM", "0")
}
}
else:
redisConfig = {
"name": os.environ.get("REDIS_CONNECTOR_NAME", "redis"),
"host": os.environ.get("REDIS_SERVER_HOST", "localhost"),
"port": os.environ.get("REDIS_SERVER_PORT", "6379"),
"options": {
"user": REDIS_SERVER_USER,
"password": REDIS_SERVER_PWD,
"db": os.environ.get("REDIS_SERVER_DB_NUM", "0")
}
}

nodeDict = {
"statsd": {
"useMetrics": os.environ.get("METRICS_ENABLED", "false"),
"host": os.environ.get("METRICS_HOST", "localhost"),
"port": os.environ.get("METRICS_PORT", "8125"),
"prefix": os.environ.get("METRICS_PREFIX", "ds.")
},
"services": {
"CoAuthoring": {
"sql": {
"type": os.environ.get("DB_TYPE", "postgres"),
"dbHost": os.environ.get("DB_HOST", "localhost"),
"dbPort": os.environ.get("DB_PORT", "5432"),
"dbUser": os.environ.get("DB_USER", "onlyoffice"),
"dbName": os.environ.get("DB_NAME", os.environ.get("DB_USER", "onlyoffice")),
"dbPass": os.environ.get("DB_PWD", "onlyoffice")
},
"redis": redisConfig,
"token": {
"enable": {
"browser": os.environ.get("JWT_ENABLED", "true"),
"request": {
"inbox": os.environ.get("JWT_ENABLED_INBOX", os.environ.get("JWT_ENABLED", "true")),
"outbox": os.environ.get("JWT_ENABLED_OUTBOX", os.environ.get("JWT_ENABLED", "true"))
}
},
"inbox": {
"header": os.environ.get("JWT_HEADER_INBOX", os.environ.get("JWT_HEADER", "Authorization")),
"inBody": os.environ.get("JWT_IN_BODY", "false")
},
"outbox": {
"header": os.environ.get("JWT_HEADER_OUTBOX", os.environ.get("JWT_HEADER", "Authorization")),
"inBody": os.environ.get("JWT_IN_BODY", "false")
}
},
"secret": {
"inbox": {
"string": os.environ.get("JWT_SECRET_INBOX", "secret")
},
"outbox": {
"string": os.environ.get("JWT_SECRET_OUTBOX", "secret")
},
"session": {
"string": os.environ.get("JWT_SECRET", "secret")
}
},
"request-filtering-agent" : {
"allowPrivateIPAddress": os.environ.get("ALLOW_PRIVATE_IP_ADDRESS", "false"),
"allowMetaIPAddress": os.environ.get("ALLOW_META_IP_ADDRESS", "false"),
"allowIPAddressList": os.environ.get("ALLOW_IP_ADDRESS_LIST", "[]"),
"denyIPAddressList": os.environ.get("DENY_IP_ADDRESS_LIST", "[]")
}
}
},
"queue": {
"type": AMQP_TYPE
},
"wopi": {
"enable": os.environ.get("WOPI_ENABLED", "false")
},
"FileConverter": {
"converter": {
"maxprocesscount": 0.001
}
},
"storage": {
"fs": {
"folderPath": "/var/lib/{0}/documentserver/App_Data/cache/files/".format(COMPANY_NAME) + os.environ.get("STORAGE_SUBDIRECTORY_NAME", "latest"),
"secretString": os.environ.get("SECURE_LINK_SECRET", "verysecretstring")
},
"storageFolderName": "files/" + os.environ.get("STORAGE_SUBDIRECTORY_NAME", "latest")
},
"persistentStorage": {
"fs": {
"folderPath": "/var/lib/{0}/documentserver/App_Data/cache/files".format(COMPANY_NAME),
"secretString": os.environ.get("SECURE_LINK_SECRET", "verysecretstring")
},
"storageFolderName": "files"
}
}

if AMQP_TYPE == "rabbitmq":
amqpConfig = {
"url": AMQP_URI
}
nodeDict['rabbitmq'] = amqpConfig
elif AMQP_TYPE == "activemq":
if AMQP_PROTO == "amqps" or AMQP_PROTO == "amqp+ssl":
ACTIVEMQ_TRANSPORT = "tls"
else:
ACTIVEMQ_TRANSPORT = "tcp"
amqpConfig = {
"connectOptions": {
"port": AMQP_PORT,
"host": AMQP_HOST,
"username": AMQP_USER,
"password": AMQP_PWD,
"transport": ACTIVEMQ_TRANSPORT
}
}
nodeDict['activemq'] = amqpConfig

NODE_CONFIG = json.dumps(nodeDict, indent=4)
os.environ['NODE_CONFIG'] = NODE_CONFIG
os.system(sys.argv[1])

147 changes: 0 additions & 147 deletions docker-entrypoint.sh

This file was deleted.

Loading