Skip to content

Commit

Permalink
Minimize size of test centos image
Browse files Browse the repository at this point in the history
  • Loading branch information
abaluha-hubs authored and gschneider-r7 committed Sep 22, 2020
1 parent 8af50b1 commit 53f97e7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ public void testAlpine() throws IOException {
@Test
public void testCentos() throws IOException {
// Given
File tarFile = new File(getClass().getClassLoader().getResource("containers/test_image_centos.tar").getFile());
ImageId expectedId = new ImageId("sha256:48650444e4191276a912ac90816a4ce1e86f76419e004d445a2e42809fec05f7");
OperatingSystem expectedOs = new OperatingSystem("Red Hat", "Linux", "Linux", "x86_64", null, "Red Hat Linux");
long expectedSize = 201543168;
File tarFile = new File(getClass().getClassLoader().getResource("containers/centos/test_image_centos.tar").getFile());
ImageId expectedId = new ImageId("sha256:bcbdfe9aa33a028bedc671ecfe56ce628ff64a8ad1b2fa46855c03955fcdc5bf");
long expectedSize = 72704;
// omit OS check because this image tar was built from scratch
long expectedLayers = 3;
long expectedPackages = 138;
long expectedPackages = 1;

// When
DockerImageAnalyzerService analyzer = new DockerImageAnalyzerService(null);
Expand All @@ -52,9 +52,9 @@ public void testCentos() throws IOException {

// Then
assertEquals(expectedId, image.getId());
assertEquals(expectedOs, image.getOperatingSystem());
assertEquals(expectedSize, image.getSize());
assertEquals(expectedLayers, image.getLayers().size());
assertEquals(expectedPackages, image.getPackages().size());
assertEquals("A set of system configuration and setup files", image.getPackages().stream().findFirst().get().getDescription());
}
}
13 changes: 13 additions & 0 deletions src/test/resources/containers/centos/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM docker.io/library/centos:centos6.10
ARG TMP_RPM="/tmp/rpm"
RUN mkdir ${TMP_RPM} && \
rpm --initdb --dbpath ${TMP_RPM} && \
yum remove setup -y -q && \
yum install --downloadonly --downloaddir=/tmp setup -y -q && \
cd ${TMP_RPM} && \
rpm --dbpath ${TMP_RPM} -i ../setup-*.noarch.rpm

FROM scratch
COPY --from=0 /tmp/rpm/Packages /var/lib/rpm/Packages
COPY --from=0 /etc/centos-release /etc/os-release
COPY --from=0 /etc/centos-release /etc/centos-release
Binary file not shown.

0 comments on commit 53f97e7

Please sign in to comment.