static Pair<VespaModel, Container> createContainerModel(Path applicationPath, FileRegistry fileRegistry,
            File preprocessedApplicationDir, Networking networkingOption, ConfigModelRepo configModelRepo) throws Exception {
        DeployLogger logger = new BaseDeployLogger();
        FilesApplicationPackage rawApplicationPackage = new FilesApplicationPackage.Builder(applicationPath.toFile())
                .includeSourceFiles(true).preprocessedDir(preprocessedApplicationDir).build();
        ApplicationPackage applicationPackage = rawApplicationPackage.preprocess(getZone(), logger);
        validateApplication(applicationPackage);
        DeployState deployState = createDeployState(applicationPackage, fileRegistry, logger);

        VespaModel root = VespaModel.createIncomplete(deployState);
        ApplicationConfigProducerRoot vespaRoot = new ApplicationConfigProducerRoot(root, "vespa", deployState.getDocumentModel(),
                deployState.getVespaVersion(), deployState.getProperties().applicationId());

        Element spec = containerRootElement(applicationPackage);
        ContainerModel containerModel = newContainerModelBuilder(networkingOption)
                .build(deployState, root, configModelRepo, vespaRoot, spec);
        containerModel.getCluster().prepare(deployState);
        initializeContainerModel(containerModel, configModelRepo);
        Container container = first(containerModel.getCluster().getContainers());

        // TODO: Separate out model finalization from the VespaModel constructor,
        // such that the above and below code to finalize the container can be
        // replaced by root.finalize();

        initializeContainer(deployState, container, spec);

        root.freezeModelTopology();
        return new Pair<>(root, container);
    }
@author Tony Vaagenes
@author gjoranv
@author ollivir
standalone-container/src/main/java/com/yahoo/container/standalone/StandaloneContainerApplication.java