From 4fe7fe76e4fc6213e79aa76240d4d2fc672d0cde Mon Sep 17 00:00:00 2001 From: Daniel Goldman Date: Wed, 4 May 2022 12:23:41 -0400 Subject: [PATCH 1/4] move installing dependencies above import files The dependencies change less than the files and take longer to build. Moving them earlier in the Dockerfile means that file changes won't force us to reinstall all the dependencies. --- Dockerfile | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index f57e76d..b48f481 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,6 +17,14 @@ RUN cd /usr/local/tomcat/webapps \ && rm geoserver.war \ && mkdir -p $GEOSERVER_DATA_DIR +# +# Install script requirements +# + +RUN apt-get update \ + && apt-get -y upgrade \ + && apt-get install -y python3 python3-pip python3-dev + VOLUME $GEOSERVER_DATA_DIR ###########docker host############### @@ -73,10 +81,7 @@ COPY get_dockerhost_ip.py /usr/local/tomcat/tmp COPY get_nginxhost_ip.py /usr/local/tomcat/tmp COPY entrypoint.sh /usr/local/tomcat/tmp -RUN apt-get update \ - && apt-get -y upgrade \ - && apt-get install -y python3 python3-pip python3-dev \ - && chmod +x /usr/local/tomcat/tmp/set_geoserver_auth.sh \ +RUN chmod +x /usr/local/tomcat/tmp/set_geoserver_auth.sh \ && chmod +x /usr/local/tomcat/tmp/setup_auth.sh \ && chmod +x /usr/local/tomcat/tmp/entrypoint.sh \ && pip install pip==9.0.3 \ From 706071b90940f74be85787fc043e89cdff35e762 Mon Sep 17 00:00:00 2001 From: Daniel Goldman Date: Wed, 4 May 2022 12:25:41 -0400 Subject: [PATCH 2/4] install pinned version of pip with other deps --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index b48f481..5620a6f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,7 +23,8 @@ RUN cd /usr/local/tomcat/webapps \ RUN apt-get update \ && apt-get -y upgrade \ - && apt-get install -y python3 python3-pip python3-dev + && apt-get install -y python3 python3-pip python3-dev \ + && pip install pip==9.0.3 VOLUME $GEOSERVER_DATA_DIR @@ -84,7 +85,6 @@ COPY entrypoint.sh /usr/local/tomcat/tmp RUN chmod +x /usr/local/tomcat/tmp/set_geoserver_auth.sh \ && chmod +x /usr/local/tomcat/tmp/setup_auth.sh \ && chmod +x /usr/local/tomcat/tmp/entrypoint.sh \ - && pip install pip==9.0.3 \ && pip install -r requirements.txt \ && chmod +x /usr/local/tomcat/tmp/get_dockerhost_ip.py \ && chmod +x /usr/local/tomcat/tmp/get_nginxhost_ip.py From 3c3168681d8a5892d625978776870e7fa8d31ad5 Mon Sep 17 00:00:00 2001 From: Daniel Goldman Date: Wed, 4 May 2022 12:27:04 -0400 Subject: [PATCH 3/4] also install python dependencies early --- Dockerfile | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5620a6f..885ebd1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,11 +20,13 @@ RUN cd /usr/local/tomcat/webapps \ # # Install script requirements # - RUN apt-get update \ && apt-get -y upgrade \ && apt-get install -y python3 python3-pip python3-dev \ - && pip install pip==9.0.3 + && pip install pip==9.0.3 \ + && mkdir -p /usr/local/tomcat/tmp +COPY requirements.txt /usr/local/tomcat/tmp +RUN pip install -r /usr/local/tomcat/tmp/requirements.txt VOLUME $GEOSERVER_DATA_DIR @@ -73,11 +75,9 @@ RUN echo export NGINX_BASE_URL=http://${NGINX_HOST}:${NGINX_PORT}/ | \ sed 's/tcp:\/\/\([^:]*\).*/\1/' >> /root/.bashrc # copy the script and perform the run of scripts from entrypoint.sh -RUN mkdir -p /usr/local/tomcat/tmp WORKDIR /usr/local/tomcat/tmp COPY set_geoserver_auth.sh /usr/local/tomcat/tmp COPY setup_auth.sh /usr/local/tomcat/tmp -COPY requirements.txt /usr/local/tomcat/tmp COPY get_dockerhost_ip.py /usr/local/tomcat/tmp COPY get_nginxhost_ip.py /usr/local/tomcat/tmp COPY entrypoint.sh /usr/local/tomcat/tmp @@ -85,7 +85,6 @@ COPY entrypoint.sh /usr/local/tomcat/tmp RUN chmod +x /usr/local/tomcat/tmp/set_geoserver_auth.sh \ && chmod +x /usr/local/tomcat/tmp/setup_auth.sh \ && chmod +x /usr/local/tomcat/tmp/entrypoint.sh \ - && pip install -r requirements.txt \ && chmod +x /usr/local/tomcat/tmp/get_dockerhost_ip.py \ && chmod +x /usr/local/tomcat/tmp/get_nginxhost_ip.py From c2aa95f7477d971716d00ce22a6df766b04fef1f Mon Sep 17 00:00:00 2001 From: Daniel Goldman Date: Thu, 5 May 2022 21:24:36 -0400 Subject: [PATCH 4/4] combine COPY of scripts --- Dockerfile | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index 885ebd1..8d63cd6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -74,19 +74,21 @@ RUN echo -n #2===>PUBLIC_PORT=${PUBLIC_PORT} RUN echo export NGINX_BASE_URL=http://${NGINX_HOST}:${NGINX_PORT}/ | \ sed 's/tcp:\/\/\([^:]*\).*/\1/' >> /root/.bashrc -# copy the script and perform the run of scripts from entrypoint.sh +# copy the scripts and set executable permission WORKDIR /usr/local/tomcat/tmp -COPY set_geoserver_auth.sh /usr/local/tomcat/tmp -COPY setup_auth.sh /usr/local/tomcat/tmp -COPY get_dockerhost_ip.py /usr/local/tomcat/tmp -COPY get_nginxhost_ip.py /usr/local/tomcat/tmp -COPY entrypoint.sh /usr/local/tomcat/tmp +COPY set_geoserver_auth.sh \ + setup_auth.sh \ + get_dockerhost_ip.py \ + get_nginxhost_ip.py \ + entrypoint.sh \ + /usr/local/tomcat/tmp/ -RUN chmod +x /usr/local/tomcat/tmp/set_geoserver_auth.sh \ - && chmod +x /usr/local/tomcat/tmp/setup_auth.sh \ - && chmod +x /usr/local/tomcat/tmp/entrypoint.sh \ - && chmod +x /usr/local/tomcat/tmp/get_dockerhost_ip.py \ - && chmod +x /usr/local/tomcat/tmp/get_nginxhost_ip.py +RUN chmod +x \ + set_geoserver_auth.sh \ + setup_auth.sh \ + get_dockerhost_ip.py \ + get_nginxhost_ip.py \ + entrypoint.sh ENV JAVA_OPTS="-Djava.awt.headless=true -XX:MaxPermSize=512m -XX:PermSize=256m -Xms512m -Xmx2048m -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:ParallelGCThreads=4 -Dfile.encoding=UTF8 -Djavax.servlet.request.encoding=UTF-8 -Djavax.servlet.response.encoding=UTF-8 -Duser.timezone=GMT -Dorg.geotools.shapefile.datetime=false -DGEOSERVER_CSRF_DISABLED=true -DPRINT_BASE_URL=http://geoserver:8080/geoserver/pdf"