This is an automated email from the ASF dual-hosted git repository.
ocket8888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
The following commit(s) were added to refs/heads/master by this push:
new bf0185c Common build stage for TO and TO Perl CDN-in-a-Box images
(#4784)
bf0185c is described below
commit bf0185ca20e2e91f257f5ebc7f475e38176c717d
Author: Zach Hoffman <[email protected]>
AuthorDate: Mon Jun 15 15:38:57 2020 -0600
Common build stage for TO and TO Perl CDN-in-a-Box images (#4784)
* Base Traffic Ops and Traffic Ops Perl CDN-in-a-Box images off of
identical build stages for their common dependencies
* Cache Traffic Ops Perl dependencies layers as build stage
---
docs/source/admin/quick_howto/ciab.rst | 2 +
infrastructure/cdn-in-a-box/traffic_ops/Dockerfile | 89 ++++++++++++----------
.../cdn-in-a-box/traffic_ops/Dockerfile-go | 55 ++++++++-----
3 files changed, 86 insertions(+), 60 deletions(-)
diff --git a/docs/source/admin/quick_howto/ciab.rst
b/docs/source/admin/quick_howto/ciab.rst
index a64f99a..81693e8 100644
--- a/docs/source/admin/quick_howto/ciab.rst
+++ b/docs/source/admin/quick_howto/ciab.rst
@@ -40,6 +40,8 @@ The CDN in a Box directory is found within the Traffic
Control repository at :fi
These can all be supplied manually via the steps in :ref:`dev-building` (for
Traffic Control component RPMs) or via some external source. Alternatively, the
:file:`infrastructure/cdn-in-a-box/Makefile` file contains recipes to build all
of these - simply run :manpage:`make(1)`\ [2]_ from the
:file:`infrastructure/cdn-in-a-box/` directory. Once all RPM dependencies have
been satisfied, run ``docker-compose build`` from the
:file:`infrastructure/cdn-in-a-box/` directory to construct the im [...]
+.. tip:: When updating CDN-in-a-Box, there is no need to remove old images
before building new ones. Docker detects which files are updated and only
reuses cached layers that have not changed.
+
Usage
-----
In a typical scenario, if the steps in `Building`_ have been followed, all
that's required to start the CDN in a Box is to run ``docker-compose up`` -
optionally with the ``-d`` flag to run without binding to the terminal - from
the :file:`infrastructure/cdn-in-a-box/` directory. This will start up the
entire stack and should take care of any needed initial configuration. The
services within the environment are by default not exposed locally to the host.
If this is the desired behavior w [...]
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile
b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile
index 582d2ce..4baba5c 100644
--- a/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile
+++ b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile
@@ -20,55 +20,59 @@
# Based on CentOS 7.2
############################################################
+# Keep the trafficops-common-deps in Dockerfile the same as
+# trafficops-common-deps in Dockerfile-go to cache the same
+# layer.
+FROM centos:7 as trafficops-common-deps
-FROM centos:7
+RUN mkdir /etc/cron.d && \
+ yum -y install
https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
&& \
+ yum -y install epel-release && \
+ yum -y install \
+ jq \
+ bind-utils \
+ net-tools \
+ gettext \
+ perl-JSON-PP \
+ mkisofs \
+ isomd5sum \
+ nmap-ncat \
+ openssl \
+ postgresql96 && \
+ yum clean all
+
+FROM trafficops-common-deps as trafficops-perl-deps
EXPOSE 443
ENV MOJO_MODE production
-RUN rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 && \
- rpm --import https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7 && \
- yum -y install
https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
&& \
- yum -y update ca-certificates && \
- yum install -y \
- epel-release \
- pgdg-redhat-latest && \
- yum install -y \
- bind-utils \
- cpanminus \
- expat-devel \
- gcc-c++ \
- gettext \
- git \
- golang \
- iproute \
- jq \
- libcurl \
- libcurl-devel \
- libidn-devel \
- libpcap-devel \
- mkisofs \
- net-tools \
- nmap-ncat \
- openssl \
- openssl-devel \
- perl \
- perl-core \
- perl-Crypt-ScryptKDF \
- perl-DBD-Pg \
- perl-DBI \
+RUN yum install -y \
+ cpanminus \
+ expat-devel \
+ gcc-c++ \
+ git \
+ golang \
+ iproute \
+ jq \
+ libcurl \
+ libcurl-devel \
+ libidn-devel \
+ libpcap-devel \
+ openssl-devel \
+ perl-core \
+ perl-Crypt-ScryptKDF\
+ perl-DBD-Pg \
+ perl-DBI \
perl-DBIx-Connector \
- perl-Digest-SHA1 \
- perl-JSON \
- perl-JSON-PP \
- perl-libwww-perl \
- perl-TermReadKey \
+ perl-Digest-SHA1 \
+ perl-JSON \
+ perl-libwww-perl \
+ perl-TermReadKey \
perl-Test-CPAN-Meta \
- perl-WWW-Curl \
- postgresql96 \
- postgresql96-devel \
- postgresql96-libs \
- tar &&\
+ perl-WWW-Curl \
+ postgresql96-devel \
+ postgresql96-libs \
+ tar && \
yum -y clean all && mkdir -p /opt/traffic_ops/app/public
ADD traffic_router/core/src/test/resources/geo/GeoLite2-City.mmdb.gz
/opt/traffic_ops/app/public/
@@ -80,6 +84,7 @@ RUN cpanm -l ./local Carton && \
rm -rf $HOME/.cpan* /tmp/Dockerfile /tmp/local.tar.gz ./cpanfile
RUN ./install_goose.sh
+FROM trafficops-perl-deps
# Override TRAFFIC_OPS_RPM arg to use a different one using --build-arg
TRAFFIC_OPS_RPM=... Can be local file or http://...
ARG TRAFFIC_OPS_RPM=infrastructure/cdn-in-a-box/traffic_ops/traffic_ops.rpm
ADD $TRAFFIC_OPS_RPM /
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile-go
b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile-go
index c062f89..8f78215 100644
--- a/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile-go
+++ b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile-go
@@ -20,25 +20,44 @@
# Based on CentOS 7.2
############################################################
-FROM centos:7
+# Keep the trafficops-common-deps in Dockerfile-go the same
+# as trafficops-common-deps in Dockerfile to cache the same
+# layer.
+FROM centos:7 as trafficops-common-deps
+
+RUN mkdir /etc/cron.d && \
+ yum -y install
https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
&& \
+ yum -y install epel-release && \
+ yum -y install \
+ jq \
+ bind-utils \
+ net-tools \
+ gettext \
+ perl-JSON-PP \
+ mkisofs \
+ isomd5sum \
+ nmap-ncat \
+ openssl \
+ postgresql96 && \
+ yum clean all
+
+FROM trafficops-common-deps
# Override TRAFFIC_OPS_RPM arg to use a different one using --build-arg
TRAFFIC_OPS_RPM=... Can be local file or http://...
-ARG TRAFFIC_OPS_RPM=infrastructure/cdn-in-a-box/traffic_ops/traffic_ops.rpm
-COPY $TRAFFIC_OPS_RPM /
+#
+ARG TRAFFIC_OPS_RPM=infrastructure/cdn-in-a-box/traffic_ops/traffic_ops.rpm
+
+COPY $TRAFFIC_OPS_RPM /
+RUN to_rpm_filename="$(basename $TRAFFIC_OPS_RPM)" && \
+ rpm --install --nodeps --verbose --hash "$to_rpm_filename" && \
+ rm "$to_rpm_filename"
+
+COPY infrastructure/cdn-in-a-box/enroller/server_template.json \
+ infrastructure/cdn-in-a-box/traffic_ops/config.sh \
+ infrastructure/cdn-in-a-box/traffic_ops/run-go.sh \
+ infrastructure/cdn-in-a-box/traffic_ops/to-access.sh \
+ /
-RUN mkdir /etc/cron.d && \
- rpm --install --nodeps --verbose --hash /$(basename $TRAFFIC_OPS_RPM)
&& \
- yum -y install
https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
&& \
- yum -y install epel-release && \
- yum -y install jq bind-utils net-tools gettext perl-JSON-PP mkisofs
isomd5sum nmap-ncat openssl postgresql96 && \
- yum clean all
-
-COPY infrastructure/cdn-in-a-box/enroller/server_template.json \
- infrastructure/cdn-in-a-box/traffic_ops/config.sh \
- infrastructure/cdn-in-a-box/traffic_ops/run-go.sh \
- infrastructure/cdn-in-a-box/traffic_ops/to-access.sh \
- /
-
-EXPOSE 443
WORKDIR /opt/traffic_ops/app
-CMD /run-go.sh
+EXPOSE 443
+CMD /run-go.sh