From 7976a98b8b62a33be60feacd7205682bd8c14063 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Tue, 19 Sep 2023 17:10:13 +0200 Subject: [PATCH] Cleanup docker images / workflow (#215) Motivation: Docker images can be quite large, lets try to cleanup things we not need. Modifications: Cleanup things during docker image creation Remove docker layer caching Remove action that free disk space Result: Docker image needs less disk-space --- .github/workflows/ci-build.yml | 15 --------------- .github/workflows/ci-deploy.yml | 24 ------------------------ .github/workflows/ci-pr.yml | 15 --------------- .github/workflows/ci-release.yml | 17 ----------------- docker/Dockerfile.centos6 | 4 ++++ docker/Dockerfile.centos7 | 13 +++++++++++-- docker/Dockerfile.centos7arm64v8 | 4 ++++ 7 files changed, 19 insertions(+), 73 deletions(-) diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 15ae4367..deb66d45 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -43,13 +43,6 @@ jobs: name: ${{ matrix.setup }} steps: - - name: Free Disk Space (Ubuntu) - uses: jlumbroso/free-disk-space@main - with: - # this might remove tools that are actually needed, - # if set to "true" but frees about 6 GB - tool-cache: false - - uses: actions/checkout@v3 # Cache .m2/repository @@ -61,14 +54,6 @@ jobs: restore-keys: | build-${{ matrix.setup }}-cache-m2-repository- - # Enable caching of Docker layers - - uses: jpribyl/action-docker-layer-caching@v0.1.1 - continue-on-error: true - with: - key: build-${{ matrix.setup }}-docker-cache-{hash} - restore-keys: | - build-${{ matrix.setup }}-docker-cache- - - name: Build docker image run: docker-compose ${{ matrix.docker-compose-build }} diff --git a/.github/workflows/ci-deploy.yml b/.github/workflows/ci-deploy.yml index c4d73c9f..53c941bb 100644 --- a/.github/workflows/ci-deploy.yml +++ b/.github/workflows/ci-deploy.yml @@ -42,13 +42,6 @@ jobs: docker-compose-run: "-f docker/docker-compose.centos-7.yaml run cross-compile-aarch64-stage-snapshot" name: stage-snapshot-${{ matrix.setup }} steps: - - name: Free Disk Space (Ubuntu) - uses: jlumbroso/free-disk-space@main - with: - # this might remove tools that are actually needed, - # if set to "true" but frees about 6 GB - tool-cache: false - - uses: actions/checkout@v3 # Cache .m2/repository @@ -60,16 +53,6 @@ jobs: restore-keys: | stage-snapshot-${{ matrix.setup }}-cache-m2-repository- - # Enable caching of Docker layers - - uses: jpribyl/action-docker-layer-caching@v0.1.1 - env: - docker-cache-name: staging-${{ matrix.setup }}-cache-docker - continue-on-error: true - with: - key: ${{ runner.os }}-staging-${{ env.docker-cache-name }}-{hash} - restore-keys: | - ${{ runner.os }}-staging-${{ env.docker-cache-name }}- - - name: Create local staging directory run: mkdir -p ~/local-staging @@ -90,13 +73,6 @@ jobs: # Wait until we have staged everything needs: stage-snapshot steps: - - name: Free Disk Space (Ubuntu) - uses: jlumbroso/free-disk-space@main - with: - # this might remove tools that are actually needed, - # if set to "true" but frees about 6 GB - tool-cache: false - - uses: actions/checkout@v3 - name: Set up JDK 8 diff --git a/.github/workflows/ci-pr.yml b/.github/workflows/ci-pr.yml index 0bcc35ca..51d8b348 100644 --- a/.github/workflows/ci-pr.yml +++ b/.github/workflows/ci-pr.yml @@ -65,13 +65,6 @@ jobs: name: ${{ matrix.setup }} steps: - - name: Free Disk Space (Ubuntu) - uses: jlumbroso/free-disk-space@main - with: - # this might remove tools that are actually needed, - # if set to "true" but frees about 6 GB - tool-cache: false - - uses: actions/checkout@v3 # Cache .m2/repository @@ -83,14 +76,6 @@ jobs: restore-keys: | build-pr-${{ matrix.setup }}-cache-m2-repository- - # Enable caching of Docker layers - - uses: jpribyl/action-docker-layer-caching@v0.1.1 - continue-on-error: true - with: - key: pr-${{ matrix.setup }}-docker-cache-{hash} - restore-keys: | - pr-${{ matrix.setup }}-docker-cache- - - name: Build docker image run: docker-compose ${{ matrix.docker-compose-build }} diff --git a/.github/workflows/ci-release.yml b/.github/workflows/ci-release.yml index 6749e60c..9ae0bda2 100644 --- a/.github/workflows/ci-release.yml +++ b/.github/workflows/ci-release.yml @@ -87,13 +87,6 @@ jobs: docker-compose-run: "-f docker/docker-compose.centos-7.yaml run cross-compile-aarch64-stage-release" name: stage-release-${{ matrix.setup }} steps: - - name: Free Disk Space (Ubuntu) - uses: jlumbroso/free-disk-space@main - with: - # this might remove tools that are actually needed, - # if set to "true" but frees about 6 GB - tool-cache: false - - name: Download release-workspace uses: actions/download-artifact@v3 with: @@ -123,16 +116,6 @@ jobs: - name: Create local staging directory run: mkdir -p ~/local-staging - # Enable caching of Docker layers - - uses: jpribyl/action-docker-layer-caching@v0.1.1 - env: - docker-cache-name: staging-${{ matrix.setup }}-cache-docker - continue-on-error: true - with: - key: ${{ runner.os }}-staging-${{ env.docker-cache-name }}-{hash} - restore-keys: | - ${{ runner.os }}-staging-${{ env.docker-cache-name }}- - - name: Build docker image working-directory: ./prepare-release-workspace/ run: docker-compose ${{ matrix.docker-compose-build }} diff --git a/docker/Dockerfile.centos6 b/docker/Dockerfile.centos6 index d867d32f..ceb727f5 100755 --- a/docker/Dockerfile.centos6 +++ b/docker/Dockerfile.centos6 @@ -39,3 +39,7 @@ RUN echo 'PATH=/root/.sdkman/candidates/java/current/bin:$PATH' >> ~/.bashrc # Prepare our own build ENV PATH /root/.sdkman/candidates/maven/current:$PATH ENV JAVA_HOME /root/.sdkman/candidates/java/current/ + +# Cleanup +RUN yum clean all && \ + rm -rf /var/cache/yum \ No newline at end of file diff --git a/docker/Dockerfile.centos7 b/docker/Dockerfile.centos7 index 2cea57b6..883d8702 100644 --- a/docker/Dockerfile.centos7 +++ b/docker/Dockerfile.centos7 @@ -3,6 +3,7 @@ FROM centos:7.9.2009 ARG gcc_version=10.2-2020.11 ENV GCC_VERSION $gcc_version ENV MAVEN_VERSION 3.9.1 +ENV SOURCE_DIR /root/source # Install requirements RUN yum install -y \ @@ -38,13 +39,21 @@ RUN bash -c "source $HOME/.sdkman/bin/sdkman-init.sh && \ RUN echo 'export JAVA_HOME="/root/.sdkman/candidates/java/current"' >> ~/.bashrc RUN echo 'PATH=/root/.sdkman/candidates/java/current/bin:$PATH' >> ~/.bashrc -WORKDIR /opt +RUN mkdir $SOURCE_DIR +WORKDIR $SOURCE_DIR # Install aarch64 gcc 10.2 toolchain RUN wget https://developer.arm.com/-/media/Files/downloads/gnu-a/$GCC_VERSION/binrel/gcc-arm-$GCC_VERSION-x86_64-aarch64-none-linux-gnu.tar.xz && \ - tar xvf gcc-arm-$GCC_VERSION-x86_64-aarch64-none-linux-gnu.tar.xz + tar xvf gcc-arm-$GCC_VERSION-x86_64-aarch64-none-linux-gnu.tar.xz && \ + mv gcc-arm-$GCC_VERSION-x86_64-aarch64-none-linux-gnu /opt/ ENV PATH="/opt/gcc-arm-$GCC_VERSION-x86_64-aarch64-none-linux-gnu/bin:${PATH}" # Prepare our own build ENV PATH /root/.sdkman/candidates/maven/current:$PATH ENV JAVA_HOME /root/.sdkman/candidates/java/current/ + + +# Cleanup +RUN rm -rf $SOURCE_DIR +RUN yum clean all && \ + rm -rf /var/cache/yum \ No newline at end of file diff --git a/docker/Dockerfile.centos7arm64v8 b/docker/Dockerfile.centos7arm64v8 index 83197ef0..bc7fc2a3 100644 --- a/docker/Dockerfile.centos7arm64v8 +++ b/docker/Dockerfile.centos7arm64v8 @@ -39,3 +39,7 @@ RUN echo 'PATH=/root/.sdkman/candidates/java/current/bin:$PATH' >> ~/.bashrc # Prepare our own build ENV PATH /root/.sdkman/candidates/maven/current:$PATH ENV JAVA_HOME /root/.sdkman/candidates/java/current/ + +# Cleanup +RUN yum clean all && \ + rm -rf /var/cache/yum \ No newline at end of file