Skip to content

Commit d270ea8

Browse files
authored
Cleanup docker images (java-native-access#583)
Motivation: Docker images can be quite large, lets try to cleanup things we not need. Modifications: - Cleanup things during docker image creation - Disable docker layer caching as it most of the times not work anyway Result: Docker image needs less disk-space
1 parent ed862a8 commit d270ea8

File tree

7 files changed

+11
-53
lines changed

7 files changed

+11
-53
lines changed

.github/workflows/ci-build.yml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,6 @@ jobs:
4444
restore-keys: |
4545
build-linux-x86_64-maven-cache-
4646
47-
# Enable caching of Docker layers
48-
- uses: jpribyl/action-docker-layer-caching@v0.1.1
49-
continue-on-error: true
50-
with:
51-
key: build-linux-x86_64-docker-cache-{hash}
52-
restore-keys: |
53-
build-linux-x86_64-docker-cache-
54-
5547
- name: Build docker image
5648
run: docker-compose -f docker/docker-compose.centos-7.yaml -f docker/docker-compose.centos-7.18.yaml build
5749

@@ -84,14 +76,6 @@ jobs:
8476
restore-keys: |
8577
build-linux-aarch64-maven-cache-
8678
87-
# Enable caching of Docker layers
88-
- uses: jpribyl/action-docker-layer-caching@v0.1.1
89-
continue-on-error: true
90-
with:
91-
key: build-linux-aarch64-docker-cache-{hash}
92-
restore-keys: |
93-
build-linux-aarch64-docker-cache-
94-
9579
- name: Build docker image
9680
run: docker-compose -f docker/docker-compose.centos-7-cross.yaml build
9781

.github/workflows/ci-deploy.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,6 @@ jobs:
6363
"password": "${{ secrets.SONATYPE_PASSWORD }}"
6464
}]
6565
66-
# Enable caching of Docker layers
67-
- uses: jpribyl/action-docker-layer-caching@v0.1.1
68-
env:
69-
docker-cache-name: staging-${{ matrix.setup }}-cache-docker
70-
continue-on-error: true
71-
with:
72-
key: ${{ runner.os }}-staging-${{ env.docker-cache-name }}-{hash}
73-
restore-keys: |
74-
${{ runner.os }}-staging-${{ env.docker-cache-name }}-
75-
7666
- name: Create local staging directory
7767
run: mkdir -p ~/local-staging
7868

.github/workflows/ci-pr.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,6 @@ jobs:
6262
${{ runner.os }}-maven-${{ matrix.setup }}-
6363
${{ runner.os }}-maven-
6464
65-
# Enable caching of Docker layers
66-
- uses: jpribyl/action-docker-layer-caching@v0.1.1
67-
continue-on-error: true
68-
with:
69-
key: build-docker-cache-${{ matrix.setup }}-{hash}
70-
restore-keys: |
71-
build-docker-cache-${{ matrix.setup }}-
72-
build-docker-cache-
73-
7465
- name: Build docker image
7566
run: docker-compose ${{ matrix.docker-compose-build }}
7667

.github/workflows/ci-release.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,16 +121,6 @@ jobs:
121121
restore-keys: |
122122
staging-${{ matrix.setup }}-maven-cache-
123123
124-
# Enable caching of Docker layers
125-
- uses: jpribyl/action-docker-layer-caching@v0.1.1
126-
env:
127-
docker-cache-name: staging-${{ matrix.setup }}-cache-docker
128-
continue-on-error: true
129-
with:
130-
key: ${{ runner.os }}-staging-${{ env.docker-cache-name }}-{hash}
131-
restore-keys: |
132-
${{ runner.os }}-staging-${{ env.docker-cache-name }}-
133-
134124
- uses: s4u/maven-settings-action@v2.2.0
135125
with:
136126
servers: |

.github/workflows/ci-verify-load.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,6 @@ jobs:
4343
restore-keys: |
4444
install-jars-linux-aarch64-maven-cache-
4545
46-
# Enable caching of Docker layers
47-
- uses: jpribyl/action-docker-layer-caching@v0.1.1
48-
continue-on-error: true
49-
with:
50-
key: pr-linux-x86_64-docker-cache-{hash}
51-
restore-keys: |
52-
pr-linux-x86_64-docker-cache-
53-
5446
- name: Build docker image
5547
run: docker-compose -f docker/docker-compose.centos-7-cross.yaml build
5648

@@ -97,6 +89,7 @@ jobs:
9789
install: |
9890
apt-get update -q -y
9991
apt-get install -q -y openjdk-11-jdk
92+
apt-get clean -q -y
10093
10194
# Check if we can load the native code on aarch64
10295
run: |

docker/Dockerfile.centos7

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,10 @@ RUN echo 'PATH=$PATH:$HOME/.cargo/bin' >> ~/.bashrc
6464
ENV PATH /root/.sdkman/candidates/maven/current:$PATH
6565
ENV JAVA_HOME /root/.sdkman/candidates/java/current
6666

67+
# Cleanup
68+
RUN rm -rf $SOURCE_DIR
69+
RUN yum clean all && \
70+
rm -rf /var/cache/yum
71+
6772
# when the JDK is GraalVM install native-image
6873
RUN if [ -O /root/.sdkman/candidates/java/current/bin/gu ]; then /root/.sdkman/candidates/java/current/bin/gu install native-image; else echo "Not GraalVM, skip installation of native-image" ; fi

docker/Dockerfile.cross_compile_aarch64

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,10 @@ RUN bash -c "source $HOME/.sdkman/bin/sdkman-init.sh && \
6565
rm -rf $HOME/.sdkman/archives/* && \
6666
rm -rf $HOME/.sdkman/tmp/*"
6767

68+
# Cleanup
69+
RUN rm -rf $SOURCE_DIR
70+
RUN yum clean all && \
71+
rm -rf /var/cache/yum
72+
6873
# Prepare our own build
6974
ENV PATH /root/.sdkman/candidates/maven/current:$PATH

0 commit comments

Comments
 (0)