mirror of
https://github.com/ggogel/seafile-containerized.git
synced 2024-11-16 09:01:38 +00:00
Handle docker ports mapping.
This commit is contained in:
parent
1832ad5acb
commit
ec8d6e638d
9
launcher
9
launcher
|
@ -9,6 +9,7 @@ local_image=local_seafile/server:latest
|
|||
dockerdir=$(cd "$(dirname $0)"; pwd -P)
|
||||
sharedir=$dockerdir/shared
|
||||
installdir=/opt/seafile/seafile-server-$version
|
||||
bootstrap_conf=$dockerdir/bootstrap/bootstrap.conf
|
||||
|
||||
cd $dockerdir
|
||||
|
||||
|
@ -37,8 +38,11 @@ init_shared() {
|
|||
}
|
||||
|
||||
set_ports() {
|
||||
ports="-p 80:80 -p 443:443"
|
||||
ports=""
|
||||
ports=$(docker run --rm -it \
|
||||
-v ${dockerdir}/scripts:/scripts \
|
||||
-v ${dockerdir}/bootstrap:/bootstrap:ro \
|
||||
$image \
|
||||
/scripts/bootstrap.py --parse-ports)
|
||||
}
|
||||
|
||||
set_bootstrap_volumes() {
|
||||
|
@ -80,7 +84,6 @@ set_volumes() {
|
|||
}
|
||||
|
||||
bootstrap() {
|
||||
local bootstrap_conf=$dockerdir/bootstrap/bootstrap.conf
|
||||
if [[ ! -e $bootstrap_conf ]]; then
|
||||
err_and_quit "The file $bootstrap_conf doesn't exist. Have you run seafile-server-setup?"
|
||||
fi
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# If you edit this file, remember to run ./launcher rebuild
|
||||
[server]
|
||||
server.hostname = seafile.example.com
|
||||
server.https = true
|
||||
admin.email = me@example.com
|
||||
admin.password = asecret
|
||||
admin.password = asecret
|
||||
server.port_mappings = 80:80,443:443
|
|
@ -7,6 +7,7 @@ setup-seafile.sh or setup-seafile-mysql.sh. It's supposed to run inside the
|
|||
container.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import os
|
||||
from os.path import abspath, basename, exists, dirname, join, isdir
|
||||
import shutil
|
||||
|
@ -56,7 +57,28 @@ def generate_local_dockerfile():
|
|||
}
|
||||
render_template('/templates/Dockerfile.template', join(generated_dir, 'Dockerfile'), context)
|
||||
|
||||
def parse_args():
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument('--parse-ports', action='store_true')
|
||||
|
||||
return ap.parse_args()
|
||||
|
||||
def do_parse_ports():
|
||||
"""
|
||||
Parse the server.port_mappings option and print docker command line port
|
||||
mapping flags like "-p 80:80 -p 443:443"
|
||||
"""
|
||||
# conf is like '80:80,443:443'
|
||||
conf = get_conf('server.port_mappings', '').strip()
|
||||
if conf:
|
||||
sys.stdout.write(' '.join(['-p {}'.format(part.strip()) for part in conf.split(',')]))
|
||||
sys.stdout.flush()
|
||||
|
||||
def main():
|
||||
args = parse_args()
|
||||
if args.parse_ports:
|
||||
do_parse_ports()
|
||||
return
|
||||
if not exists(shared_seafiledir):
|
||||
os.mkdir(shared_seafiledir)
|
||||
if not exists(generated_dir):
|
||||
|
@ -92,4 +114,5 @@ def main():
|
|||
shutil.move(src, shared_seafiledir)
|
||||
|
||||
if __name__ == '__main__':
|
||||
# TODO: validate the content of bootstrap.conf is valid
|
||||
main()
|
||||
|
|
Loading…
Reference in a new issue