Merge pull request #188 from haiwen/seafile-logs-nginx-conf

mv seafile/logs to /shared/seafile/logs and persistence nginx's confi…
This commit is contained in:
Hulk 2019-11-19 10:48:43 +08:00 committed by GitHub
commit 2f74f30ee0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 15 deletions

View file

@ -1,4 +1,4 @@
server_version=7.0.9 server_version=7.0.11
base_image=seafileltd/base-mc:18.04 base_image=seafileltd/base-mc:18.04
base_image_squashed=seafileltd/base-mc:18.04-squashed base_image_squashed=seafileltd/base-mc:18.04-squashed

View file

@ -1,7 +1,7 @@
FROM seafileltd/pro-base-mc:18.04 FROM seafileltd/pro-base-mc:18.04
WORKDIR /opt/seafile WORKDIR /opt/seafile
ENV SEAFILE_VERSION=7.0.9 SEAFILE_SERVER=seafile-pro-server ENV SEAFILE_VERSION=7.0.11 SEAFILE_SERVER=seafile-pro-server
RUN mkdir -p /etc/my_init.d RUN mkdir -p /etc/my_init.d

View file

@ -61,8 +61,9 @@ def init_letsencrypt():
'https': False, 'https': False,
'domain': domain, 'domain': domain,
} }
render_template('/templates/seafile.nginx.conf.template', if not os.path.isfile('/shared/nginx/conf/seafile.nginx.conf'):
'/etc/nginx/sites-enabled/seafile.nginx.conf', context) render_template('/templates/seafile.nginx.conf.template',
'/etc/nginx/sites-enabled/seafile.nginx.conf', context)
call('nginx -s reload') call('nginx -s reload')
time.sleep(2) time.sleep(2)
@ -84,12 +85,16 @@ def generate_local_nginx_conf():
'https': is_https(), 'https': is_https(),
'domain': domain, 'domain': domain,
} }
render_template(
'/templates/seafile.nginx.conf.template',
'/etc/nginx/sites-enabled/seafile.nginx.conf',
context
)
if not os.path.isfile('/shared/nginx/conf/seafile.nginx.conf'):
render_template(
'/templates/seafile.nginx.conf.template',
'/etc/nginx/sites-enabled/seafile.nginx.conf',
context
)
nginx_etc_file = '/etc/nginx/sites-enabled/seafile.nginx.conf'
nginx_shared_file = '/shared/nginx/conf/seafile.nginx.conf'
call('mv {0} {1} && ln -sf {1} {0}'.format(nginx_etc_file, nginx_shared_file))
def is_https(): def is_https():
return get_conf('SEAFILE_SERVER_LETSENCRYPT', 'false').lower() == 'true' return get_conf('SEAFILE_SERVER_LETSENCRYPT', 'false').lower() == 'true'
@ -189,7 +194,7 @@ COMPRESS_CACHE_BACKEND = 'locmem'""")
# container, we need to move them to the shared volume # container, we need to move them to the shared volume
# #
# e.g move "/opt/seafile/seafile-data" to "/shared/seafile/seafile-data" # e.g move "/opt/seafile/seafile-data" to "/shared/seafile/seafile-data"
files_to_copy = ['conf', 'ccnet', 'seafile-data', 'seahub-data', 'pro-data'] files_to_copy = ['conf', 'ccnet', 'seafile-data', 'seahub-data', 'pro-data', 'logs']
for fn in files_to_copy: for fn in files_to_copy:
src = join(topdir, fn) src = join(topdir, fn)
dst = join(shared_seafiledir, fn) dst = join(shared_seafiledir, fn)

View file

@ -18,12 +18,17 @@ if [[ $TIME_ZONE != "" ]]; then
fi fi
fi fi
if [[ -e /shared/logs/seafile ]]; then
mv /shared/logs/seafile /shared/seafile/logs
fi
dirs=( dirs=(
conf conf
ccnet ccnet
seafile-data seafile-data
seahub-data seahub-data
pro-data pro-data
logs
seafile-license.txt seafile-license.txt
) )
@ -34,12 +39,14 @@ for d in ${dirs[*]}; do
fi fi
done done
if [[ ! -e /shared/logs/seafile ]]; then
mkdir -p /shared/logs/seafile
fi
rm -rf /opt/seafile/logs && ln -sf /shared/logs/seafile/ /opt/seafile/logs
if [[ ! -e /shared/logs/var-log ]]; then if [[ ! -e /shared/logs/var-log ]]; then
mv /var/log /shared/logs/var-log mv /var/log /shared/logs/var-log
fi fi
rm -rf /var/log && ln -sf /shared/logs/var-log /var/log rm -rf /var/log && ln -sf /shared/logs/var-log /var/log
mkdir -p /shared/nginx/conf/
if [[ -e /shared/nginx/conf/seafile.nginx.conf ]]; then
rm -rf /etc/nginx/sites-enabled/seafile.nginx.conf && \
ln -sf /shared/nginx/conf/seafile.nginx.conf /etc/nginx/sites-enabled
fi