Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

import static com.github.dockerjava.core.FilePathUtil.relativize;

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.zip.GZIPOutputStream;

import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
Expand All @@ -16,8 +18,8 @@ public static File archiveTARFiles(File base, Iterable<File> files, String archi
throws IOException {
File tarFile = new File(FileUtils.getTempDirectoryPath(), archiveNameWithOutExtension + ".tar");
tarFile.deleteOnExit();
TarArchiveOutputStream tos = new TarArchiveOutputStream(new FileOutputStream(tarFile));
try {
try(TarArchiveOutputStream tos = new TarArchiveOutputStream(new GZIPOutputStream(
new BufferedOutputStream(new FileOutputStream(tarFile))))) {
tos.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
for (File file : files) {
TarArchiveEntry tarEntry = new TarArchiveEntry(file);
Expand All @@ -36,8 +38,6 @@ public static File archiveTARFiles(File base, Iterable<File> files, String archi
}
tos.closeArchiveEntry();
}
} finally {
tos.close();
}

return tarFile;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ public void onComplete() {

@Override
public void close() throws IOException {
closed = true;
if (stream != null)
stream.close();
completed.countDown();
closed = true;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.zip.GZIPInputStream;

import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
Expand Down Expand Up @@ -43,7 +45,8 @@ private File extractFileByName(File archive, String filenameToExtract) throws IO
expectedFile.delete();
assertThat(expectedFile.exists(), is(false));

TarArchiveInputStream tarArchiveInputStream = new TarArchiveInputStream(new FileInputStream(archive));
TarArchiveInputStream tarArchiveInputStream = new TarArchiveInputStream(new GZIPInputStream(
new BufferedInputStream(new FileInputStream(archive))));
TarArchiveEntry entry;
while ((entry = tarArchiveInputStream.getNextTarEntry()) != null) {
String individualFiles = entry.getName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,4 +225,17 @@ public void testAddAndCopySubstitution() throws Exception {
String response = dockerfileBuild(baseDir);
assertThat(response, containsString("testENVSubstitution successfully completed"));
}

@Test
public void testBuilderPerformance() throws Exception {
File baseDir = new File(Thread.currentThread().getContextClassLoader().getResource("nginx").getFile());

String imageId = buildImage(baseDir);

InspectImageResponse inspectImageResponse = dockerClient.inspectImageCmd(imageId).exec();
assertThat(inspectImageResponse, not(nullValue()));
LOG.info("Image Inspect: {}", inspectImageResponse.toString());

assertThat(inspectImageResponse.getAuthor(), equalTo("Guillaume J. Charmes \"[email protected]\""));
}
}