def PublishContainerSelection(publishSelection, selectionToPublish): composeFiles = publishSelection[BuildTools.FILES_KEY] publishComposeFile = BuildTools.GetAvailableComposeFilename( 'publish', selectionToPublish) DockerComposeTools.MergeComposeFiles(composeFiles, publishComposeFile) try: DockerComposeTools.PublishDockerImages(publishComposeFile) except: BuildTools.RemoveComposeFileIfNotPreserved(publishComposeFile, publishSelection) raise if BuildTools.ADDITIONAL_TAG_KEY in publishSelection: DockerComposeTools.PublishDockerImagesWithNewTag( publishComposeFile, publishSelection[BuildTools.ADDITIONAL_TAG_KEY]) if BuildTools.ADDITIONAL_TAGS_KEY in publishSelection: for tag in publishSelection[BuildTools.ADDITIONAL_TAGS_KEY]: DockerComposeTools.PublishDockerImagesWithNewTag( publishComposeFile, tag) if BuildTools.COMPOSE_FILE_WITH_DIGESTS_KEY in publishSelection: composeFileWithDigests = publishSelection[ BuildTools.COMPOSE_FILE_WITH_DIGESTS_KEY] BuildTools.GenerateComposeFileWithDigests(composeFiles, composeFileWithDigests) BuildTools.RemoveComposeFileIfNotPreserved(publishComposeFile, publishSelection)
def BuildSelection(buildSelection, selectionToBuild): cwd = BuildTools.TryChangeToDirectoryAndGetCwd(buildSelection) oldEnvironmentVariable = BuildTools.AddEnvironmentVariablesFromSelection(buildSelection) BuildTools.HandleTerminalCommandsSelection(buildSelection) TerminalTools.LoadDefaultEnvironmentVariablesFile() if BuildTools.FILES_KEY in buildSelection: composeFiles = buildSelection[BuildTools.FILES_KEY] buildComposeFile = BuildTools.GetAvailableComposeFilename('build', selectionToBuild) DockerComposeTools.MergeComposeFiles(composeFiles, buildComposeFile) try: DockerComposeTools.DockerComposeBuild([buildComposeFile]) except: BuildTools.RemoveComposeFileIfNotPreserved(buildComposeFile, buildSelection) raise if BuildTools.ADDITIONAL_TAG_KEY in buildSelection: DockerComposeTools.TagImages(buildComposeFile, buildSelection[BuildTools.ADDITIONAL_TAG_KEY]) if BuildTools.ADDITIONAL_TAGS_KEY in buildSelection: for tag in buildSelection[BuildTools.ADDITIONAL_TAGS_KEY]: DockerComposeTools.TagImages(buildComposeFile, tag) if SAVE_IMAGES_KEY in buildSelection: outputFolder = buildSelection[SAVE_IMAGES_KEY] DockerComposeTools.SaveImages(buildComposeFile, outputFolder) if BuildTools.COMPOSE_FILE_WITH_DIGESTS_KEY in buildSelection: composeFileWithDigests = buildSelection[BuildTools.COMPOSE_FILE_WITH_DIGESTS_KEY] BuildTools.GenerateComposeFileWithDigests(composeFiles, composeFileWithDigests) BuildTools.RemoveComposeFileIfNotPreserved(buildComposeFile, buildSelection) BuildTools.RemoveEnvironmentVariables(oldEnvironmentVariable) os.chdir(cwd)