private String normalizeDest(final String filePath) {
    // if the path is a file (i.e. not a directory), remove the last part of the path so that we
    // end up with:
    //   ADD foo/bar.txt foo/
    // instead of
    //   ADD foo/bar.txt foo/bar.txt
    // This is to prevent issues when adding tar.gz or other archives where Docker will
    // automatically expand the archive into the "dest", so
    //  ADD foo/x.tar.gz foo/x.tar.gz
    // results in x.tar.gz being expanded *under* the path foo/x.tar.gz/stuff...
    final File file = new File(filePath);

    final String dest;
    // need to know the path relative to destination to test if it is a file or directory,
    // but only remove the last part of the path if there is a parent (i.e. don't remove a
    // parent path segment from "file.txt")
    if (new File(getDestination(), filePath).isFile()) {
      if (file.getParent() != null) {
        // remove file part of path
        dest = separatorsToUnix(file.getParent()) + "/";
      } else {
        // working with a simple "ADD file.txt"
        dest = ".";
      }
    } else {
      dest = separatorsToUnix(file.getPath());
    }

    return dest;
  }
Set the networking mode for the RUN instructions during build
src/main/java/com/spotify/docker/BuildMojo.java