From 0cad77b310516317b2270e626cf79de9843d9e09 Mon Sep 17 00:00:00 2001 From: Andre Riesco Date: Fri, 9 Feb 2024 14:52:36 -0300 Subject: [PATCH] Dockerfile: Remove debug build dirs before building the release version Remove the code from the debug builds, inside this container, to build the release version from a clean build Signed-off-by: Andre Riesco --- cConsole/Dockerfile | 4 ++++ cmakeConsole/Dockerfile | 3 +++ cppConsole/Dockerfile | 4 ++++ cppQML/Dockerfile | 4 ++++ cppSlint/.dockerignore | 3 +-- cppSlint/Dockerfile | 14 ++++++++++---- cppSlint/Dockerfile.debug | 4 ++++ nodeElectron/Dockerfile | 5 ++++- nodeJSTypeScript/Dockerfile | 5 +++++ rustConsole/Dockerfile | 5 +++++ rustSlint/Dockerfile | 5 +++++ zigConsole/Dockerfile | 4 ++++ 12 files changed, 53 insertions(+), 7 deletions(-) diff --git a/cConsole/Dockerfile b/cConsole/Dockerfile index c0f05aee0..ef8182bd1 100644 --- a/cConsole/Dockerfile +++ b/cConsole/Dockerfile @@ -33,6 +33,10 @@ RUN apt-get -q -y update && \ COPY . ${APP_ROOT} WORKDIR ${APP_ROOT} +# Remove the code from the debug builds, inside this container, to build the +# release version from a clean build +RUN rm -rf ${APP_ROOT}/build-${IMAGE_ARCH} + # Compile the application RUN if [ "$IMAGE_ARCH" = "arm64" ] ; then \ make ARCH=${IMAGE_ARCH} CC=aarch64-linux-gnu-gcc ; \ diff --git a/cmakeConsole/Dockerfile b/cmakeConsole/Dockerfile index 66cad2245..323c9d5a8 100644 --- a/cmakeConsole/Dockerfile +++ b/cmakeConsole/Dockerfile @@ -34,6 +34,9 @@ RUN apt-get -q -y update && \ COPY . ${APP_ROOT} WORKDIR ${APP_ROOT} +# Remove the code from the debug builds, inside this container, to build the +# release version from a clean build +RUN rm -rf ${APP_ROOT}/build-${IMAGE_ARCH} RUN if [ "$IMAGE_ARCH" = "arm64" ] ; then \ cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc -Bbuild-${IMAGE_ARCH} ; \ diff --git a/cppConsole/Dockerfile b/cppConsole/Dockerfile index 48a449f62..1291b00af 100644 --- a/cppConsole/Dockerfile +++ b/cppConsole/Dockerfile @@ -33,6 +33,10 @@ RUN apt-get -q -y update && \ COPY . ${APP_ROOT} WORKDIR ${APP_ROOT} +# Remove the code from the debug builds, inside this container, to build the +# release version from a clean build +RUN rm -rf ${APP_ROOT}/build-${IMAGE_ARCH} + # Compile the application RUN if [ "$IMAGE_ARCH" = "arm64" ] ; then \ make ARCH=${IMAGE_ARCH} CC=aarch64-linux-gnu-g++ ; \ diff --git a/cppQML/Dockerfile b/cppQML/Dockerfile index f729ebe8e..e3d4edadf 100644 --- a/cppQML/Dockerfile +++ b/cppQML/Dockerfile @@ -83,6 +83,10 @@ RUN apt-get -q -y update && \ COPY . ${APP_ROOT} WORKDIR ${APP_ROOT} +# Remove the code from the debug builds, inside this container, to build the +# release version from a clean build +RUN rm -rf ${APP_ROOT}/build-${IMAGE_ARCH} + RUN if [ "$IMAGE_ARCH" = "arm64" ] ; then \ cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc -Bbuild-${IMAGE_ARCH} ; \ elif [ "$IMAGE_ARCH" = "arm" ] ; then \ diff --git a/cppSlint/.dockerignore b/cppSlint/.dockerignore index 232c84126..392e1dd33 100644 --- a/cppSlint/.dockerignore +++ b/cppSlint/.dockerignore @@ -1,2 +1 @@ -credentials.zip -build/*/CMakeFiles \ No newline at end of file +credentials.zip \ No newline at end of file diff --git a/cppSlint/Dockerfile b/cppSlint/Dockerfile index 5c144b923..3fe1039dc 100644 --- a/cppSlint/Dockerfile +++ b/cppSlint/Dockerfile @@ -55,10 +55,12 @@ ENV CMAKE_GENERATOR=Ninja COPY . ${APP_ROOT} WORKDIR ${APP_ROOT} -RUN mkdir -p build \ - && cd build \ - && cmake .. \ - && cmake --build . +# Remove the code from the debug builds, inside this container, to build the +# release version from a clean build +RUN rm -rf ${APP_ROOT}/build + +RUN cmake -DCMAKE_BUILD_TYPE=Release -B build/${IMAGE_ARCH} -S . \ + && cmake --build build/${IMAGE_ARCH} # BUILD ------------------------------------------------------------------------ @@ -108,6 +110,10 @@ ENV SLINT_FULLSCREEN=1 # configuration defined in settings.json COPY --from=Build ${APP_ROOT}/build/${IMAGE_ARCH} ${APP_ROOT} +# Remove the CMakeFiles directory, that is just needed for the build and not +# for the execution +RUN rm -rf ${APP_ROOT}/CMakeFiles + # "cd" (enter) into the APP_ROOT directory WORKDIR ${APP_ROOT} diff --git a/cppSlint/Dockerfile.debug b/cppSlint/Dockerfile.debug index f7c4c435a..6e2eb8736 100644 --- a/cppSlint/Dockerfile.debug +++ b/cppSlint/Dockerfile.debug @@ -118,4 +118,8 @@ RUN rm -r /etc/ssh/ssh*key && \ # in settings.json. COPY --chown=$SSHUSERNAME:$SSHUSERNAME ./build/${IMAGE_ARCH} ${APP_ROOT} +# Remove the CMakeFiles directory, that is just needed for the build and not +# for the execution +RUN rm -rf ${APP_ROOT}/CMakeFiles + CMD [ "/usr/sbin/sshd", "-D" ] diff --git a/nodeElectron/Dockerfile b/nodeElectron/Dockerfile index bcfdcae58..f3ef73625 100644 --- a/nodeElectron/Dockerfile +++ b/nodeElectron/Dockerfile @@ -84,9 +84,12 @@ RUN npm install -g npm@8.10.0 COPY . ${APP_ROOT} WORKDIR ${APP_ROOT} -# Remove the out directory, that has the debug build + +# Remove the code from the debug builds, inside this container, to build the +# release version from a clean build RUN rm -rf ${APP_ROOT}/out + RUN npm install # build the application diff --git a/nodeJSTypeScript/Dockerfile b/nodeJSTypeScript/Dockerfile index d942ae342..f802b35d5 100644 --- a/nodeJSTypeScript/Dockerfile +++ b/nodeJSTypeScript/Dockerfile @@ -53,6 +53,11 @@ RUN npm install -g ts-node COPY . ${APP_ROOT} WORKDIR ${APP_ROOT} +# Remove the code from the debug builds, inside this container, to build the +# release version from a clean build +RUN rm -rf ${APP_ROOT}/out + + RUN if [ "$IMAGE_ARCH" = "arm64" ] ; then \ npm run output-arm64; \ elif [ "$IMAGE_ARCH" = "arm" ] ; then \ diff --git a/rustConsole/Dockerfile b/rustConsole/Dockerfile index edf1ebfc4..8c7bf4d8d 100644 --- a/rustConsole/Dockerfile +++ b/rustConsole/Dockerfile @@ -48,6 +48,11 @@ RUN rustup target add $(cat ~/rust-toolchain-arch.txt) COPY . ${APP_ROOT} WORKDIR ${APP_ROOT} +# Remove the code from the debug builds, inside this container, to build the +# release version from a clean build +RUN rm -rf ${APP_ROOT}/target + + RUN TARGET=$(cat ~/rust-toolchain-arch.txt) && \ cargo build --release --target $TARGET && \ mkdir -p build && \ diff --git a/rustSlint/Dockerfile b/rustSlint/Dockerfile index 1fa81872a..7784e111e 100644 --- a/rustSlint/Dockerfile +++ b/rustSlint/Dockerfile @@ -62,6 +62,11 @@ ENV RUST_FONTCONFIG_DLOPEN=on COPY . ${APP_ROOT} WORKDIR ${APP_ROOT} +# Remove the code from the debug builds, inside this container, to build the +# release version from a clean build +RUN rm -rf ${APP_ROOT}/target + + # BUILD ------------------------------------------------------------------------ RUN TARGET=$(cat /rust-toolchain-arch.txt) && \ diff --git a/zigConsole/Dockerfile b/zigConsole/Dockerfile index 71bb5f09f..017f09cb2 100644 --- a/zigConsole/Dockerfile +++ b/zigConsole/Dockerfile @@ -70,6 +70,10 @@ RUN chmod +x ${ZIG_PATH}/zig COPY . ${APP_ROOT} WORKDIR ${APP_ROOT} +# Remove the code from the debug builds, inside this container, to build the +# release version from a clean build +RUN rm -rf ${APP_ROOT}/target + # zig optimizers: # (Debug | ReleaseSafe) w/ dbg-info + runtime stacktrace (compiler safety), # (ReleaseSmall | ReleaseFast) no runtime stacktrace (undefined & fast)