-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-entrypoint.sh
executable file
·130 lines (118 loc) · 5.46 KB
/
docker-entrypoint.sh
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/bin/bash
set -e
if [ -z "${PIP_PARAMS}" ]; then
PIP_PARAMS=""
fi
# Only in build time we should have a secret with
# admin password
if [ -f "/run/secrets/ADMIN_PASSWORD" ]; then
echo "Found /run/secrets/ADMIN_PASSWORD file, using it as secret"
ADMIN_PASSWORD=$(cat /run/secrets/ADMIN_PASSWORD);
export ADMIN_PASSWORD=${ADMIN_PASSWORD}
fi
# CLIENT HOME
CLIENT_HOME="/data/$(hostname)/$(hostid)"
export CLIENT_HOME=$CLIENT_HOME
USER="$(id -u)"
# Create directories to be used by Plone
mkdir -p /data/filestorage /data/blobstorage /data/cache /data/log $CLIENT_HOME
if [ "$USER" = '0' ]; then
find /data -not -user plone -exec chown plone:plone {} \+
sudo="gosu plone"
else
sudo=""
fi
# MAIN ENV Vars
[ -z ${SECURITY_POLICY_IMPLEMENTATION+x} ] && export SECURITY_POLICY_IMPLEMENTATION=C
[ -z ${VERBOSE_SECURITY+x} ] && export VERBOSE_SECURITY=off
[ -z ${DEFAULT_ZPUBLISHER_ENCODING+x} ] && export DEFAULT_ZPUBLISHER_ENCODING=utf-8
[ -z ${DEBUG_MODE+x} ] && export DEBUG_MODE=off
[ -z ${ZOPE_FORM_MEMORY_LIMIT+x} ] && export ZOPE_FORM_MEMORY_LIMIT=50MB
# ZODB ENV Vars
[ -z ${ZODB_CACHE_SIZE+x} ] && export ZODB_CACHE_SIZE=50000
if [[ -v RELSTORAGE_DSN ]]; then
MSG="Using Relstorage configuration"
CONF=relstorage.conf
# Relstorage ENV Vars
[ -z ${RELSTORAGE_NAME+x} ] && export RELSTORAGE_NAME=storage
[ -z ${RELSTORAGE_READ_ONLY+x} ] && export RELSTORAGE_READ_ONLY=off
[ -z ${RELSTORAGE_KEEP_HISTORY+x} ] && export RELSTORAGE_KEEP_HISTORY=true
[ -z ${RELSTORAGE_COMMIT_LOCK_TIMEOUT+x} ] && export RELSTORAGE_COMMIT_LOCK_TIMEOUT=30
[ -z ${RELSTORAGE_CREATE_SCHEMA+x} ] && export RELSTORAGE_CREATE_SCHEMA=true
[ -z ${RELSTORAGE_SHARED_BLOB_DIR+x} ] && export RELSTORAGE_SHARED_BLOB_DIR=false
[ -z ${RELSTORAGE_BLOB_CACHE_SIZE+x} ] && export RELSTORAGE_BLOB_CACHE_SIZE=100mb
[ -z ${RELSTORAGE_BLOB_CACHE_SIZE_CHECK+x} ] && export RELSTORAGE_BLOB_CACHE_SIZE_CHECK=10
[ -z ${RELSTORAGE_BLOB_CACHE_SIZE_CHECK_EXTERNAL+x} ] && export RELSTORAGE_BLOB_CACHE_SIZE_CHECK_EXTERNAL=false
[ -z ${RELSTORAGE_BLOB_CHUNK_SIZE+x} ] && export RELSTORAGE_BLOB_CHUNK_SIZE=1048576
[ -z ${RELSTORAGE_CACHE_LOCAL_MB+x} ] && export RELSTORAGE_CACHE_LOCAL_MB=10
[ -z ${RELSTORAGE_CACHE_LOCAL_OBJECT_MAX+x} ] && export RELSTORAGE_CACHE_LOCAL_OBJECT_MAX=16384
[ -z ${RELSTORAGE_CACHE_LOCAL_COMPRESSION+x} ] && export RELSTORAGE_CACHE_LOCAL_COMPRESSION=none
[ -z ${RELSTORAGE_CACHE_DELTA_SIZE_LIMIT+x} ] && export RELSTORAGE_CACHE_DELTA_SIZE_LIMIT=100000
elif [[ -v ZEO_ADDRESS ]]; then
MSG="Using ZEO configuration"
CONF=zeo.conf
# Check ZEO variables
[ -z ${ZEO_SHARED_BLOB_DIR+x} ] && export ZEO_SHARED_BLOB_DIR=off
[ -z ${ZEO_READ_ONLY+x} ] && export ZEO_READ_ONLY=false
[ -z ${ZEO_CLIENT_READ_ONLY_FALLBACK+x} ] && export ZEO_CLIENT_READ_ONLY_FALLBACK=false
[ -z ${ZEO_STORAGE+x} ] && export ZEO_STORAGE=1
[ -z ${ZEO_CLIENT_CACHE_SIZE+x} ] && export ZEO_CLIENT_CACHE_SIZE=128MB
[ -z ${ZEO_DROP_CACHE_RATHER_VERIFY+x} ] && export ZEO_DROP_CACHE_RATHER_VERIFY=false
else
MSG="Using default configuration"
CONF=zope.conf
fi
# Handle CORS
$sudo /app/bin/python /app/scripts/cors.py
# Handle ADDONS installation
if [[ -v ADDONS ]]; then
echo "======================================================================================="
echo "Installing ADDONS ${ADDONS}"
echo "THIS IS NOT MEANT TO BE USED IN PRODUCTION"
echo "Read about it: https://github.com/plone/plone-backend/#extending-from-this-image"
echo "======================================================================================="
/app/bin/pip install ${ADDONS} ${PIP_PARAMS}
fi
# Handle development addons
if [[ -v DEVELOP ]]; then
echo "======================================================================================="
echo "Installing DEVELOPment addons ${DEVELOP}"
echo "THIS IS NOT MEANT TO BE USED IN PRODUCTION"
echo "Read about it: https://github.com/plone/plone-backend/#extending-from-this-image"
echo "======================================================================================="
/app/bin/pip install --editable ${DEVELOP} ${PIP_PARAMS}
fi
if [[ "$1" == "start" ]]; then
# Handle Site creation
if [[ -v SITE ]]; then
export TYPE=${TYPE:-volto}
echo "======================================================================================="
echo "Creating Plone ${TYPE} SITE: ${SITE}"
echo "Additional profiles: ${PROFILES}"
echo "THIS IS NOT MEANT TO BE USED IN PRODUCTION"
echo "Read about it: https://github.com/plone/plone-backend/#extending-from-this-image"
echo "======================================================================================="
export SITE_ID=${SITE}
$sudo /app/bin/zconsole run etc/${CONF} /app/scripts/create_site.py
fi
echo $MSG
exec $sudo /app/bin/runwsgi -v etc/zope.ini config_file=${CONF}
elif [[ "$1" == "create-classic" ]]; then
export TYPE=classic
exec $sudo /app/bin/zconsole run etc/${CONF} /app/scripts/create_site.py
elif [[ "$1" == "create-volto" ]]; then
export TYPE=volto
exec $sudo /app/bin/zconsole run etc/${CONF} /app/scripts/create_site.py
elif [[ "$1" == "create-site" ]]; then
export TYPE=volto
exec $sudo /app/bin/zconsole run etc/${CONF} /app/scripts/create_site.py
elif [[ "$1" == "console" ]]; then
exec $sudo /app/bin/zconsole debug etc/${CONF}
elif [[ "$1" == "run-maintenance" ]]; then
exec $sudo /app/bin/zconsole run etc/${CONF} /app/scripts/run_maintenance.py ${@:2}
elif [[ "$1" == "run" ]]; then
exec $sudo /app/bin/zconsole run etc/${CONF} ${@:2}
else
# Custom
exec "$@"
fi