From b8eec630134bed03d87a4201f066cc00b86a8228 Mon Sep 17 00:00:00 2001 From: Thomas Wunschel <4302898+wuschi@users.noreply.github.com> Date: Mon, 30 Mar 2020 20:56:11 +0200 Subject: [PATCH 1/2] Make docker maintainer and image prefix configurable. Remove nginx from image. Closes #200. --- image/Makefile | 28 +++++++++++++++------------- image/base/Dockerfile | 7 +------ image/pro_base/Dockerfile | 3 ++- image/pro_seafile/Dockerfile | 5 +++-- image/seafile/Dockerfile | 7 ++++--- scripts/bootstrap.py | 4 ++++ scripts/start.py | 5 ----- 7 files changed, 29 insertions(+), 30 deletions(-) diff --git a/image/Makefile b/image/Makefile index a9d848ce..d681053e 100644 --- a/image/Makefile +++ b/image/Makefile @@ -1,15 +1,17 @@ server_version=7.0.11 +maintainer?=seafileltd +image_prefix?= -base_image=seafileltd/base-mc:18.04 -base_image_squashed=seafileltd/base-mc:18.04-squashed -pro_base_image=seafileltd/pro-base-mc:18.04 -pro_base_image_squashed=seafileltd/pro-base-mc:18.04-squashed -server_image=seafileltd/seafile-mc:$(server_version) -server_image_squashed=seafileltd/seafile-mc:$(server_version)-squashed -pro_server_image=seafileltd/seafile-pro-mc:$(server_version) -pro_server_image_squashed=seafileltd/seafile-pro-mc:$(server_version)-squashed -latest_pro_server_image=seafileltd/seafile-pro-mc:latest -latest_server_image=seafileltd/seafile-mc:latest +base_image=$(maintainer)/$(image_prefix)base-mc:18.04 +base_image_squashed=$(maintainer)/$(image_prefix)base-mc:18.04-squashed +pro_base_image=$(maintainer)/$(image_prefix)pro-base-mc:18.04 +pro_base_image_squashed=$(maintainer)/$(image_prefix)pro-base-mc:18.04-squashed +server_image=$(maintainer)/$(image_prefix)seafile-mc:$(server_version) +server_image_squashed=$(maintainer)/$(image_prefix)seafile-mc:$(server_version)-squashed +pro_server_image=$(maintainer)/$(image_prefix)seafile-pro-mc:$(server_version) +pro_server_image_squashed=$(maintainer)/$(image_prefix)seafile-pro-mc:$(server_version)-squashed +latest_pro_server_image=$(maintainer)/$(image_prefix)seafile-pro-mc:latest +latest_server_image=$(maintainer)/$(image_prefix)seafile-mc:latest all: @echo @@ -26,20 +28,20 @@ base: docker rmi `docker images --filter "dangling=true" -q --no-trunc` server: - cd seafile && cp -rf ../../scripts ./ && docker build -t $(server_image) . + cd seafile && cp -rf ../../scripts ./ && docker build -t $(server_image) --build-arg base=$(base_image) . docker-squash --tag $(server_image_squashed) $(server_image) --from-layer=$(base_image) docker tag $(server_image_squashed) $(server_image) docker tag $(server_image) $(latest_server_image) docker rmi `docker images --filter "dangling=true" -q --no-trunc` pro-base: - cd pro_base && docker build -t $(pro_base_image) . + cd pro_base && docker build -t $(pro_base_image) --build-arg base=$(base_image) . docker-squash --tag $(pro_base_image_squashed) $(pro_base_image) docker tag $(pro_base_image_squashed) $(pro_base_image) docker rmi `docker images --filter "dangling=true" -q --no-trunc` pro-server: - cd pro_seafile && cp -rf ../../scripts ./ && docker build -t $(pro_server_image) . + cd pro_seafile && cp -rf ../../scripts ./ && docker build -t $(pro_server_image) --build-arg base=$(pro_base_image) . docker-squash --tag $(pro_server_image_squashed) $(pro_server_image) --from-layer=$(pro_base_image) docker tag $(pro_server_image_squashed) $(pro_server_image) docker tag $(pro_server_image) $(latest_pro_server_image) diff --git a/image/base/Dockerfile b/image/base/Dockerfile index 256d4185..549b36bb 100644 --- a/image/base/Dockerfile +++ b/image/base/Dockerfile @@ -7,7 +7,7 @@ ENV UPDATED_AT=20180412 \ CMD ["/sbin/my_init", "--", "bash", "-l"] -RUN apt-get update -qq && apt-get -qq -y install nginx +RUN apt-get update -qq # Utility tools RUN apt-get install -qq -y vim htop net-tools psmisc git wget curl @@ -26,11 +26,6 @@ RUN pip install -r /tmp/requirements.txt COPY services /services -RUN mkdir -p /etc/service/nginx && \ - rm -f /etc/nginx/sites-enabled/* /etc/nginx/conf.d/* && \ - mv /services/nginx.conf /etc/nginx/nginx.conf && \ - mv /services/nginx.sh /etc/service/nginx/run - RUN mkdir -p /etc/my_init.d && rm -f /etc/my_init.d/00_regen_ssh_host_keys.sh RUN rm -rf \ diff --git a/image/pro_base/Dockerfile b/image/pro_base/Dockerfile index 1847c965..79cfe7c6 100644 --- a/image/pro_base/Dockerfile +++ b/image/pro_base/Dockerfile @@ -1,4 +1,5 @@ -FROM seafileltd/base-mc:18.04 +ARG base=seafileltd/base-mc:18.04 +FROM ${base} # syslog-ng and syslog-forwarder would mess up the container stdout, not good # when debugging/upgrading. diff --git a/image/pro_seafile/Dockerfile b/image/pro_seafile/Dockerfile index b32fb6cf..b96ec1a9 100644 --- a/image/pro_seafile/Dockerfile +++ b/image/pro_seafile/Dockerfile @@ -1,4 +1,5 @@ -FROM seafileltd/pro-base-mc:18.04 +ARG base=seafileltd/pro-base-mc:18.04 +FROM ${base} WORKDIR /opt/seafile ENV SEAFILE_VERSION=7.0.11 SEAFILE_SERVER=seafile-pro-server @@ -17,6 +18,6 @@ ADD scripts/create_data_links.sh /etc/my_init.d/01_create_data_links.sh COPY scripts /scripts COPY templates /templates -EXPOSE 80 +EXPOSE 8000 CMD ["/sbin/my_init", "--", "/scripts/start.py"] diff --git a/image/seafile/Dockerfile b/image/seafile/Dockerfile index 22281ae0..1cc3fc9a 100644 --- a/image/seafile/Dockerfile +++ b/image/seafile/Dockerfile @@ -1,4 +1,5 @@ -FROM seafileltd/base-mc:18.04 +ARG base=seafileltd/base-mc:18.04 +FROM ${base} # For suport set local time zone. RUN export DEBIAN_FRONTEND=noninteractive && apt-get update && apt-get install tzdata -y @@ -7,7 +8,7 @@ WORKDIR /opt/seafile RUN mkdir -p /etc/my_init.d -ENV SEAFILE_VERSION=7.0.4 SEAFILE_SERVER=seafile-server +ENV SEAFILE_VERSION=7.0.5 SEAFILE_SERVER=seafile-server RUN mkdir -p /opt/seafile/ && \ curl -sSL -o - https://download.seadrive.org/seafile-server_${SEAFILE_VERSION}_x86-64.tar.gz \ @@ -21,6 +22,6 @@ ADD scripts/create_data_links.sh /etc/my_init.d/01_create_data_links.sh COPY scripts /scripts COPY templates /templates -EXPOSE 80 +EXPOSE 8000 CMD ["/sbin/my_init", "--", "/scripts/start.py"] diff --git a/scripts/bootstrap.py b/scripts/bootstrap.py index 4231ec6e..ae47109c 100755 --- a/scripts/bootstrap.py +++ b/scripts/bootstrap.py @@ -134,6 +134,10 @@ def init_seafile_server(): # call('''sed -i -e 's/if not mysql_root_passwd/if not mysql_root_passwd and "MYSQL_ROOT_PASSWD" not in os.environ/g' {}''' # .format(get_script('setup-seafile-mysql.py'))) + # Change bind port of gunicorn + call('''sed -i 's/127.0.0.1:8000/0.0.0.0:8000/' {}''' + .format(get_script('setup-seafile-mysql.py'))) + # Change the script to disable check MYSQL_USER_HOST call('''sed -i -e '/def validate_mysql_user_host(self, host)/a \ \ \ \ \ \ \ \ return host' {}''' .format(get_script('setup-seafile-mysql.py'))) diff --git a/scripts/start.py b/scripts/start.py index d1268583..6c575e8e 100755 --- a/scripts/start.py +++ b/scripts/start.py @@ -47,11 +47,6 @@ def main(): if not exists(generated_dir): os.makedirs(generated_dir) - if is_https(): - init_letsencrypt() - generate_local_nginx_conf() - call('nginx -s reload') - wait_for_mysql() init_seafile_server() From 3408dc0767ab0864a0da03f3815c76e52707314e Mon Sep 17 00:00:00 2001 From: Thomas Wunschel <4302898+wuschi@users.noreply.github.com> Date: Mon, 30 Mar 2020 23:02:44 +0200 Subject: [PATCH 2/2] Also expose port 8082 (seaf-server) --- image/pro_seafile/Dockerfile | 1 + image/seafile/Dockerfile | 1 + 2 files changed, 2 insertions(+) diff --git a/image/pro_seafile/Dockerfile b/image/pro_seafile/Dockerfile index b96ec1a9..5e1aadf9 100644 --- a/image/pro_seafile/Dockerfile +++ b/image/pro_seafile/Dockerfile @@ -19,5 +19,6 @@ COPY scripts /scripts COPY templates /templates EXPOSE 8000 +EXPOSE 8082 CMD ["/sbin/my_init", "--", "/scripts/start.py"] diff --git a/image/seafile/Dockerfile b/image/seafile/Dockerfile index 1cc3fc9a..5969ab93 100644 --- a/image/seafile/Dockerfile +++ b/image/seafile/Dockerfile @@ -23,5 +23,6 @@ COPY scripts /scripts COPY templates /templates EXPOSE 8000 +EXPOSE 8082 CMD ["/sbin/my_init", "--", "/scripts/start.py"]