Prechádzať zdrojové kódy

Speed up docker build process

George S. Baugh 5 rokov pred
rodič
commit
72459ab0e4
6 zmenil súbory, kde vykonal 37 pridanie a 26 odobranie
  1. 3 22
      Dockerfile
  2. 25 0
      Dockerfile.build
  3. 1 1
      Makefile
  4. 3 1
      Readme.md
  5. 2 2
      dockerdeploy.sh
  6. 3 0
      fulldeploy.sh

+ 3 - 22
Dockerfile

@@ -1,34 +1,15 @@
-FROM ubuntu:latest
-ARG port=5000
+FROM troglodyne/base:latest AS tcms
 
+ARG port=5000
 LABEL description="tCMS: a Perl CMS by Troglodyne LLC"
 
 EXPOSE $port/tcp
 
-USER root
-RUN useradd tcms
-RUN apt-get update
-RUN apt-get install -y make apt-utils mlocate
-
 ADD . /home/tcms
-RUN mkdir /home/tcms/.tcms
 RUN chown -R tcms /home/tcms
 
-WORKDIR /home/tcms
-
-RUN apt-get install -y locales
-RUN localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
-ENV LANG en_US.utf8
-
-ENV DEBIAN_FRONTEND=noninteractive
-RUN ln -fs /usr/share/zoneinfo/UTC /etc/localtime
-RUN apt-get install -y tzdata
-RUN dpkg-reconfigure --frontend noninteractive tzdata
-
-RUN make depend
-RUN updatedb
-
 USER tcms
+
 RUN make install
 RUN make reset-dummy-data
 CMD /usr/bin/starman -p $port www/server.psgi

+ 25 - 0
Dockerfile.build

@@ -0,0 +1,25 @@
+FROM ubuntu:latest AS base
+
+USER root
+RUN useradd tcms
+RUN apt-get update
+RUN apt-get install -y make apt-utils mlocate
+
+ADD ./Makefile /home/tcms/Makefile
+RUN mkdir /home/tcms/.tcms
+RUN mkdir -p /home/tcms/www/scripts
+RUN chown -R tcms /home/tcms
+
+WORKDIR /home/tcms
+
+RUN apt-get install -y locales
+RUN localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
+ENV LANG en_US.utf8
+
+ENV DEBIAN_FRONTEND=noninteractive
+RUN ln -fs /usr/share/zoneinfo/UTC /etc/localtime
+RUN apt-get install -y tzdata
+RUN dpkg-reconfigure --frontend noninteractive tzdata
+
+RUN make depend
+RUN updatedb

+ 1 - 1
Makefile

@@ -20,6 +20,6 @@ depend:
 	apt-get install -y libuuid-tiny-perl libcapture-tiny-perl libconfig-simple-perl libdbi-perl libfile-slurper-perl libfile-touch-perl
 	apt-get install -y libfile-copy-recursive-perl libxml-rss-perl libmodule-install-perl
 	apt-get install -y libmoose-perl libmoosex-types-datetime-perl libxml-libxml-perl
-	cpanm Mojo::File Date::Format WWW::SitemapIndex::XML WWW::Sitemap::XML HTTP::Body Pod::Html URL::Encode
+	cpanm -n Mojo::File Date::Format WWW::SitemapIndex::XML WWW::Sitemap::XML HTTP::Body Pod::Html URL::Encode
 	wget -O www/scripts/fgEmojiPicker.js https://github.com/woody180/vanilla-javascript-emoji-picker/raw/master/fgEmojiPicker.js
 	wget -O www/scripts/full-emoji-list.json https://github.com/woody180/vanilla-javascript-emoji-picker/raw/master/full-emoji-list.json

+ 3 - 1
Readme.md

@@ -13,7 +13,9 @@ Deployment is currently:
 A Dockerfile and deployment scripts are provided for your convenience in building/running containers based on this:
 ```
 # Build and run the server
-./docker-deploy.sh
+./fulldeploy.sh
+# Just run the server with latest changes
+./dockerdeploy.sh
 # Extract configuration & local data, then spin down the server
 ./docker-exfil.sh
 ```

+ 2 - 2
dockerdeploy.sh

@@ -1,3 +1,3 @@
 #!/bin/sh
-sudo docker build -t troglodyne/tcms .
-sudo docker run -dp 5000:5000 troglodyne/tcms:latest /usr/bin/starman -p 5000 www/server.psgi
+docker build -t troglodyne/tcms .
+docker run -dp 5000:5000 troglodyne/tcms:latest "//usr/bin/starman" "www/server.psgi"

+ 3 - 0
fulldeploy.sh

@@ -0,0 +1,3 @@
+#!/bin/sh
+docker build -t troglodyne/base . -f Dockerfile.build
+./dockerdeploy.sh