Skip to content

Commit

Permalink
update script to 4.3.10
Browse files Browse the repository at this point in the history
  • Loading branch information
haiphamhoang committed May 2, 2024
1 parent 3c51238 commit 6247875
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 25 deletions.
9 changes: 2 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -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/`
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
35 changes: 33 additions & 2 deletions templates/enterpoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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."

Expand Down
35 changes: 22 additions & 13 deletions templates/init_config.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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:
Expand All @@ -147,7 +148,7 @@
gunicorn_config = """
daemon = True
workers = 5
threads = 2
threads = 5
# default localhost:8000
bind = '127.0.0.1:8000'
Expand Down Expand Up @@ -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 = """
Expand All @@ -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;
Expand Down

0 comments on commit 6247875

Please sign in to comment.