@VisibleForTesting
  static boolean isGzipped(Path path) throws IOException {
    try (InputStream inputStream = Files.newInputStream(path)) {
      inputStream.mark(2);
      int magic = (inputStream.read() & 0xff) | ((inputStream.read() << 8) & 0xff00);
      return magic == GZIPInputStream.GZIP_MAGIC;
    }
  }
Checks the first two bytes of a file to see if it has been gzipped.

@param path the file to check
@return {@code true} if the file is gzipped, {@code false} if not
@throws IOException if reading the file fails
@see <a href="http://www.zlib.org/rfc-gzip.html#file-format">GZIP file format</a>
jib-core/src/main/java/com/google/cloud/tools/jib/builder/steps/LocalBaseImageSteps.java