From 132dd1339e62f408d8fe25e09829337337d9bc46 Mon Sep 17 00:00:00 2001 From: Daniel McCoy Stephenson Date: Wed, 31 Jan 2024 14:09:53 -0700 Subject: [PATCH 1/3] Removed docker setup & build/push actions from `ci.yml` --- .github/workflows/ci.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6deb13a2..7982b484 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,10 +44,6 @@ jobs: cmake --build _cmake_build --target install - name: Install sonar-scanner and build-wrapper uses: sonarsource/sonarcloud-github-c-cpp@v2 # This Action Installs sonar cloud and build wrapper to run sonar scan analysis - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - name: Build - uses: docker/build-push-action@v5 - name: Build and Generate test coverage run: | cd $GITHUB_WORKSPACE From d83423800c9426fcc544f87850ac21a2beff3ec2 Mon Sep 17 00:00:00 2001 From: Daniel McCoy Stephenson Date: Wed, 31 Jan 2024 14:38:13 -0700 Subject: [PATCH 2/3] Modified dockerfiles to reduce package installation duplication --- Dockerfile | 32 ++++++++++++++++++-------------- Dockerfile-nsv | 32 ++++++++++++++++++-------------- Dockerfile.standalone | 32 ++++++++++++++++++-------------- Dockerfile.testing | 33 ++++++++++++++++++--------------- 4 files changed, 72 insertions(+), 57 deletions(-) diff --git a/Dockerfile b/Dockerfile index 18dc3b5d..11d35b3e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,21 +1,31 @@ -# === BUILDER IMAGE === -FROM alpine:3.12 as builder +# === RUNTIME DEPENDENCIES IMAGE === +FROM alpine:3.12 as runtime-deps USER root WORKDIR /cvdi-stream -ENV DEBIAN_FRONTEND=noninteractive - # update the package manager RUN apk update +# add runtime dependencies +RUN apk add --upgrade --no-cache \ + bash \ + librdkafka \ + librdkafka-dev + +# === BUILDER IMAGE === +FROM runtime-deps as builder +USER root + +WORKDIR /cvdi-stream + +ENV DEBIAN_FRONTEND=noninteractive + # add build dependencies RUN apk add --upgrade --no-cache --virtual .build-deps \ cmake \ g++ \ - make \ - librdkafka \ - librdkafka-dev + make # add the source and build files ADD CMakeLists.txt /cvdi-stream @@ -30,17 +40,11 @@ ADD ./config /cvdi-stream/config RUN export LD_LIBRARY_PATH=/usr/local/lib && mkdir /cvdi-stream-build && cd /cvdi-stream-build && cmake /cvdi-stream && make # === RUNTIME IMAGE === -FROM alpine:3.12 +FROM runtime-deps USER root WORKDIR /cvdi-stream -# add runtime dependencies -RUN apk add --upgrade --no-cache \ - bash \ - librdkafka \ - librdkafka-dev - # copy the built files from the builder COPY --from=builder /cvdi-stream-build/ /cvdi-stream-build/ COPY --from=builder /cvdi-stream /cvdi-stream diff --git a/Dockerfile-nsv b/Dockerfile-nsv index 4d14caf8..28c3139e 100644 --- a/Dockerfile-nsv +++ b/Dockerfile-nsv @@ -1,5 +1,20 @@ +# === RUNTIME DEPENDENCIES IMAGE === +FROM alpine:3.12 as runtime-deps +USER root + +WORKDIR /cvdi-stream + +# update the package manager +RUN apk update + +# add runtime dependencies +RUN apk add --upgrade --no-cache \ + bash \ + librdkafka \ + librdkafka-dev + # === BUILDER IMAGE === -FROM alpine:3.12 as builder +FROM runtime-deps as builder USER root ARG PPM_CONFIG_FILE ARG PPM_MAP_FILE @@ -8,16 +23,11 @@ WORKDIR /cvdi-stream ENV DEBIAN_FRONTEND=noninteractive -# update the package manager -RUN apk update - # add build dependencies RUN apk add --upgrade --no-cache --virtual .build-deps \ cmake \ g++ \ - make \ - librdkafka \ - librdkafka-dev + make # add the source and build files ADD CMakeLists.txt /cvdi-stream @@ -34,17 +44,11 @@ ADD ./config /cvdi-stream/config RUN export LD_LIBRARY_PATH=/usr/local/lib && mkdir /cvdi-stream-build && cd /cvdi-stream-build && cmake /cvdi-stream && make # === RUNTIME IMAGE === -FROM alpine:3.12 +FROM runtime-deps USER root WORKDIR /cvdi-stream -# add runtime dependencies -RUN apk add --upgrade --no-cache \ - bash \ - librdkafka \ - librdkafka-dev - # copy the built files from the builder COPY --from=builder /cvdi-stream-build/ /cvdi-stream-build/ COPY --from=builder /cvdi-stream /cvdi-stream diff --git a/Dockerfile.standalone b/Dockerfile.standalone index fa6a70d4..bc786cd2 100644 --- a/Dockerfile.standalone +++ b/Dockerfile.standalone @@ -1,21 +1,31 @@ -# === BUILDER IMAGE === -FROM alpine:3.12 as builder +# === RUNTIME DEPENDENCIES IMAGE === +FROM alpine:3.12 as runtime-deps USER root WORKDIR /cvdi-stream -ENV DEBIAN_FRONTEND=noninteractive - # update the package manager RUN apk update +# add runtime dependencies +RUN apk add --upgrade --no-cache \ + bash \ + librdkafka \ + librdkafka-dev + +# === BUILDER IMAGE === +FROM runtime-deps as builder +USER root + +WORKDIR /cvdi-stream + +ENV DEBIAN_FRONTEND=noninteractive + # add build dependencies RUN apk add --upgrade --no-cache --virtual .build-deps \ cmake \ g++ \ - make \ - librdkafka \ - librdkafka-dev + make # add the source and build files ADD CMakeLists.txt /cvdi-stream @@ -30,17 +40,11 @@ ADD ./config /cvdi-stream/config RUN export LD_LIBRARY_PATH=/usr/local/lib && mkdir /cvdi-stream-build && cd /cvdi-stream-build && cmake /cvdi-stream && make # === RUNTIME IMAGE === -FROM alpine:3.12 +FROM runtime-deps USER root WORKDIR /cvdi-stream -# add runtime dependencies -RUN apk add --upgrade --no-cache \ - bash \ - librdkafka \ - librdkafka-dev - # copy the built files from the builder COPY --from=builder /cvdi-stream-build/ /cvdi-stream-build/ COPY --from=builder /cvdi-stream /cvdi-stream diff --git a/Dockerfile.testing b/Dockerfile.testing index 6a68b5fe..f24d3ada 100644 --- a/Dockerfile.testing +++ b/Dockerfile.testing @@ -1,21 +1,31 @@ -# === BUILDER IMAGE === -FROM alpine:3.12 as builder +# === RUNTIME DEPENDENCIES IMAGE === +FROM alpine:3.12 as runtime-deps USER root WORKDIR /cvdi-stream -ENV DEBIAN_FRONTEND=noninteractive - # update the package manager RUN apk update +# add runtime dependencies +RUN apk add --upgrade --no-cache \ + bash \ + librdkafka \ + librdkafka-dev + +# === BUILDER IMAGE === +FROM runtime-deps as builder +USER root + +WORKDIR /cvdi-stream + +ENV DEBIAN_FRONTEND=noninteractive + # add build dependencies RUN apk add --upgrade --no-cache --virtual .build-deps \ cmake \ g++ \ - make \ - librdkafka \ - librdkafka-dev + make # add the source and build files ADD CMakeLists.txt /cvdi-stream @@ -30,18 +40,11 @@ ADD ./config /cvdi-stream/config RUN export LD_LIBRARY_PATH=/usr/local/lib && mkdir /cvdi-stream-build && cd /cvdi-stream-build && cmake /cvdi-stream && make # === RUNTIME IMAGE === -FROM alpine:3.12 +FROM runtime-deps USER root WORKDIR /cvdi-stream -# add runtime dependencies -RUN apk add --upgrade --no-cache \ - bash \ - python3 \ - librdkafka \ - librdkafka-dev - # copy the built files from the builder COPY --from=builder /cvdi-stream-build/ /cvdi-stream-build/ COPY --from=builder /cvdi-stream /cvdi-stream From 56da6dd28eaad355ba536963126dd680005d2d2e Mon Sep 17 00:00:00 2001 From: Daniel McCoy Stephenson Date: Wed, 31 Jan 2024 14:46:31 -0700 Subject: [PATCH 3/3] Added python3 runtime dependency back into `Dockerfile.testing` --- Dockerfile.testing | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile.testing b/Dockerfile.testing index f24d3ada..572cce68 100644 --- a/Dockerfile.testing +++ b/Dockerfile.testing @@ -10,6 +10,7 @@ RUN apk update # add runtime dependencies RUN apk add --upgrade --no-cache \ bash \ + python3 \ librdkafka \ librdkafka-dev