diff --git a/README.md b/README.md index 9b34335..3f21ada 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,14 @@ # docker-seatable -## Env +## Additional Env - REDIS_HOST: `string` - MEMCACHED_HOST: `string` -- SEATABLE_SERVER_URL_FORCE_HTTPS: `bool` - - it's useful when use with reverse proxy like traefik. - DB_ROOT_PASSWD_FILE: `filepath` +## For Upgrade new image version - -# Dev - -## Upgrade ### Checking new script 1. Run container with new seatable/seatable-enterprise:latest version, using default [docker-compose.yml](https://manual.seatable.io/docker/Enterprise-Edition/Deploy%20SeaTable-EE%20with%20Docker/#downloading-and-modifying-docker-composeyml) 2. copy file at `/templates/` diff --git a/docker-compose.yml b/docker-compose.yml index 407bb83..001c0fc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -29,7 +29,7 @@ services: build: context: . args: - SEATABLE_VERSION: '3.1.13' + SEATABLE_VERSION: '4.3.10' container_name: seatable ports: - "80:80" # HTTP port on the Docker host and the port in the container -- must be changed if port 80 is already in use on Docker host @@ -38,8 +38,8 @@ services: - /opt/seatable/seatable-data:/shared # Volume of SeaTable (directory for persistent storage) and mount point in container -- can be changed (not advised) environment: - DB_HOST=seatable-mysql - #- DB_ROOT_PASSWD=hellopassword # Root password of MySQL -- must be changed to the value set above - - DB_ROOT_PASSWD_FILE=/run/secrets/shared_mysql_root_password + - DB_ROOT_PASSWD=hellopassword # Root password of MySQL -- must be changed to the value set above + #- DB_ROOT_PASSWD_FILE=/run/secrets/shared_mysql_root_password - REDIS_HOST=seatable-redis - MEMCACHED_HOST=seatable-memcached - SEATABLE_SERVER_URL_FORCE_HTTPS=True diff --git a/templates/enterpoint.sh b/templates/enterpoint.sh index 70d8644..69621a3 100755 --- a/templates/enterpoint.sh +++ b/templates/enterpoint.sh @@ -15,7 +15,6 @@ function load_env() { file_env_var="${env_var}_FILE" if [[ -n "${!file_env_var:-}" ]]; then if [[ -r "${!file_env_var:-}" ]]; then - export "ok=abcd" export "${env_var}=$(< "${!file_env_var}")" unset "${file_env_var}" else @@ -24,11 +23,16 @@ function load_env() { fi } + +is_first_start=0 # init config if [ "`ls -A /opt/seatable/conf`" = "" ]; then log "Start init" + + is_first_start=1 + load_env - + /templates/seatable.sh init-sql &>> /opt/seatable/logs/init.log /templates/seatable.sh init &>> /opt/seatable/logs/init.log @@ -100,6 +104,33 @@ else fi +# auto start +if [[ $SEATABLE_START_MODE = "cluster" ]] || [[ -f /opt/seatable/conf/seatable-controller.conf ]] ;then + # cluster mode + log "Start cluster server" + /templates/seatable.sh start + +else + # auto upgrade sql + python3 /templates/upgrade_sql.py &>> /opt/seatable/logs/init.log + sleep 5 + + # auto start + log "Start server" + /templates/seatable.sh start + + # init superuser + if [[ ${is_first_start} -eq 1 ]]; then + sleep 5 + log "Auto create superuser" + /templates/seatable.sh auto-create-superuser ${is_first_start} &>> /opt/seatable/logs/init.log & + fi + +fi + +log "For more startup information, please check the /opt/seatable/logs/init.log" + + # log "This is an idle script (infinite loop) to keep container running." diff --git a/templates/init_config.py b/templates/init_config.py index 931810d..e1a2ec2 100755 --- a/templates/init_config.py +++ b/templates/init_config.py @@ -1,23 +1,17 @@ import os from django.core.management.utils import get_random_secret_key - REDIS_HOST = os.getenv('REDIS_HOST', 'redis') MEMCACHED_HOST = os.getenv('MEMCACHED_HOST', 'memcached') DB_HOST = os.getenv('DB_HOST', 'db') DB_ROOT_PASSWD = os.getenv('DB_ROOT_PASSWD', '') - -# SEATABLE_ADMIN_EMAIL = os.getenv('SEATABLE_ADMIN_EMAIL') -# SEATABLE_ADMIN_PASSWORD = os.getenv('SEATABLE_ADMIN_PASSWORD') +SEATABLE_SERVER_PROTOCOL = os.getenv('SEATABLE_SERVER_PROTOCOL', '') SEATABLE_SERVER_LETSENCRYPT = os.getenv('SEATABLE_SERVER_LETSENCRYPT', 'False') - SEATABLE_SERVER_HOSTNAME = os.getenv('SEATABLE_SERVER_HOSTNAME', '127.0.0.1') -SEATABLE_SERVER_URL_FORCE_HTTPS = os.getenv('SEATABLE_SERVER_URL_FORCE_HTTPS', SEATABLE_SERVER_LETSENCRYPT) - - PRIVATE_KEY = get_random_secret_key() -server_prefix = 'https://' if SEATABLE_SERVER_URL_FORCE_HTTPS == 'True' else 'http://' +server_prefix = 'https://' if (SEATABLE_SERVER_LETSENCRYPT == 'True' or SEATABLE_SERVER_PROTOCOL == 'https') else 'http://' SERVER_URL = server_prefix + SEATABLE_SERVER_HOSTNAME +TIME_ZONE = os.getenv('TIME_ZONE', 'UTC') # seatable-controller @@ -32,6 +26,8 @@ DTABLE_EVENTS_TASK_MODE=all DTABLE_SERVER_MEMORY_SIZE=8192 DTABLE_SERVER_PING_TIMEOUT=20 +ENABLE_DTABLE_SERVER_SLAVE=false +DTABLE_SERVER_SLAVE_MEMORY_SIZE=4096 """ # seatable-controller.conf do not auto init @@ -134,8 +130,13 @@ ENABLE_USER_TO_SET_NUMBER_SEPARATOR = True -""" % (DB_HOST, DB_ROOT_PASSWD, MEMCACHED_HOST, get_random_secret_key(), PRIVATE_KEY, - SERVER_URL, SERVER_URL, SERVER_URL, SERVER_URL, SERVER_URL) +TIME_ZONE = '%s' + +DISABLE_ADDRESSBOOK_V1 = True +ENABLE_ADDRESSBOOK_V2 = True + +""" % (DB_HOST, DB_ROOT_PASSWD, MEMCACHED_HOST, get_random_secret_key(), PRIVATE_KEY, + SERVER_URL, SERVER_URL, SERVER_URL, SERVER_URL, SERVER_URL, TIME_ZONE) if not os.path.exists(dtable_web_config_path): with open(dtable_web_config_path, 'w') as f: @@ -147,7 +148,7 @@ gunicorn_config = """ daemon = True workers = 5 -threads = 2 +threads = 5 # default localhost:8000 bind = '127.0.0.1:8000' @@ -263,6 +264,14 @@ f.write(dtable_events_config) +# current version +current_version = str(os.environ.get('server_version')) +version_path = '/opt/seatable/conf/current_version.txt' +if not os.path.exists(version_path): + with open(version_path, 'w') as fp: + fp.write(current_version) + + # nginx nginx_config_path = '/opt/seatable/conf/nginx.conf' nginx_common_config = """ @@ -286,7 +295,7 @@ return 204; } proxy_pass http://127.0.0.1:8000; - proxy_set_header Host $host; + proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $server_name;