From cd68cae1f5fc25503260c2e2fe36301a4965616d Mon Sep 17 00:00:00 2001
From: David Schmitz <schmitz@lrz.de>
Date: Thu, 29 Jun 2023 07:33:00 +0000
Subject: [PATCH] feature/exabgp_with_docker-compose2: try to exploit docker
 build cache by splitting install-debian:sh run in 3 phases; use decouple venv
 dir from main FOD dir (avoid mixing python bin/lib stuff within container
 with python bin/libs outside) - delta

---
 docker-compose/Dockerfile_FOD       |  2 ++
 docker-compose/Dockerfile_FOD.1step | 16 +++++++++++++++
 docker-compose/Dockerfile_FOD.3step | 30 +++++++++++++++++++++++++++++
 3 files changed, 48 insertions(+)
 create mode 100644 docker-compose/Dockerfile_FOD.1step
 create mode 100644 docker-compose/Dockerfile_FOD.3step

diff --git a/docker-compose/Dockerfile_FOD b/docker-compose/Dockerfile_FOD
index 3dd455bd..dac1ca39 100644
--- a/docker-compose/Dockerfile_FOD
+++ b/docker-compose/Dockerfile_FOD
@@ -17,6 +17,8 @@ EXPOSE 8000
 COPY install-debian.sh /opt/FOD
 RUN ./install-debian.sh --basesw_os --here__with_venv_relative --supervisord 
 
+RUN apt-get install -y pkg-config
+
 # build step2 (exploit docker build cache, only redone if ./install-debian.sh or requirements.txt changed)
 COPY requirements.txt /opt/FOD
 RUN ./install-debian.sh --basesw_python --here__with_venv_relative --supervisord 
diff --git a/docker-compose/Dockerfile_FOD.1step b/docker-compose/Dockerfile_FOD.1step
new file mode 100644
index 00000000..b91652bc
--- /dev/null
+++ b/docker-compose/Dockerfile_FOD.1step
@@ -0,0 +1,16 @@
+FROM ubuntu:latest
+LABEL maintainer="FOD"
+ENV DEBIAN_FRONTEND=noninteractive
+RUN apt-get update -y && apt-get install -y locales
+RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
+    dpkg-reconfigure --frontend=noninteractive locales && \
+    update-locale LANG=en_US.UTF-8
+ENV LANG en_US.UTF-8
+COPY docker-compose/fod_setup_environment-1step.sh /opt/setup_environment.sh
+RUN mkdir -p /var/run/supervisor
+RUN apt-get update -y && apt-get -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' --assume-yes -fuy dist-upgrade
+RUN apt-get install -y git less man make gcc strace ltrace lsof file vim tshark tcpdump curl wget net-tools sudo psutils procps iptables iputils-ping iputils-tracepath hping3 iproute2 supervisor pkg-config
+RUN useradd exabgp
+WORKDIR /opt/FOD
+EXPOSE 8000
+CMD /opt/setup_environment.sh && supervisord -c docker-compose/fod_supervisord.conf
diff --git a/docker-compose/Dockerfile_FOD.3step b/docker-compose/Dockerfile_FOD.3step
new file mode 100644
index 00000000..dac1ca39
--- /dev/null
+++ b/docker-compose/Dockerfile_FOD.3step
@@ -0,0 +1,30 @@
+FROM ubuntu:latest
+LABEL maintainer="FOD"
+ENV DEBIAN_FRONTEND=noninteractive
+RUN apt-get update -y && apt-get install -y locales
+RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
+    dpkg-reconfigure --frontend=noninteractive locales && \
+    update-locale LANG=en_US.UTF-8
+ENV LANG en_US.UTF-8
+RUN apt-get update -y && apt-get -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' --assume-yes -fuy dist-upgrade
+RUN apt-get install -y git less man make gcc strace ltrace lsof file vim tshark tcpdump curl wget net-tools sudo psutils procps iptables iputils-ping iputils-tracepath hping3 iproute2 supervisor
+RUN useradd exabgp
+RUN mkdir -p /var/run/supervisor /opt/FOD
+WORKDIR /opt/FOD
+EXPOSE 8000
+
+# build step1 (exploit docker build cache, only redone if ./install-debian.sh changed)
+COPY install-debian.sh /opt/FOD
+RUN ./install-debian.sh --basesw_os --here__with_venv_relative --supervisord 
+
+RUN apt-get install -y pkg-config
+
+# build step2 (exploit docker build cache, only redone if ./install-debian.sh or requirements.txt changed)
+COPY requirements.txt /opt/FOD
+RUN ./install-debian.sh --basesw_python --here__with_venv_relative --supervisord 
+
+# build step3 will be done in first CMD / run
+#COPY docker-compose/fod_setup_environment.sh /opt/setup_environment.sh # includes tryinfo to redo step 1 + step 2 again (at least ensure everything is really up-to-date)
+#COPY docker-compose/fod_setup_environment.sh /opt/setup_environment.sh # only to the least minimal adaptions necessary in the bind-mounted FOD dir are performed
+COPY docker-compose/fod_setup_environment-step3.sh /opt/setup_environment.sh
+CMD /opt/setup_environment.sh && supervisord -c docker-compose/fod_supervisord.conf
-- 
GitLab