From 3b7d398358b242d245d8305d4c1b98917a9f15ca Mon Sep 17 00:00:00 2001 From: Pedro Rauiz Estigarribia Gestal Date: Mon, 20 May 2024 17:32:49 -0300 Subject: [PATCH 1/5] Added cli/.run folder to share run-configs through Rider (its similar to sharing a Postman library between a team); Added --beamable-dev flag to NewMicroservice command (will create the SAMS with the BeamableDev dockerfile) - Moved set-packages.sh script into repo root and added sync-rider-run-settings.sh script to root as well (to share run-configs across team) as a form of discoverability and workflow improvement - Updated template project to contain two Dockerfiles one for beamable developers and another for customers; the BeamableDev one sets us up to build microservice images that reference our own locally built nuget packages --- .gitignore | 3 + cli/.run/BEAM-Linux-Cli-Install.run.xml | 17 +++++ cli/.run/BEAM-Mac-Cli-Install.run.xml | 17 +++++ ...-Mac-Sync-Rider-Run-Settings-Unity.run.xml | 17 +++++ cli/.run/BEAM-Windows-Cli-Install.run.xml | 17 +++++ ...dows-Sync-Rider-Run-Settings-Unity.run.xml | 17 +++++ ...ows-Sync-Rider-Run-Settings-Unreal.run.xml | 17 +++++ .../TEMPLATE-SDK-Content-Bulk-Edit.run.xml | 20 ++++++ cli/.run/TEMPLATE-SDK-Content-Publish.run.xml | 20 ++++++ cli/.run/TEMPLATE-SDK-Content-Pull.run.xml | 20 ++++++ cli/.run/TEMPLATE-SDK-Content-Reset.run.xml | 20 ++++++ cli/.run/TEMPLATE-SDK-Content-Status.run.xml | 20 ++++++ ...-SDK-Generate-Interface-CLI-Unreal.run.xml | 20 ++++++ .../TEMPLATE-SDK-OAPI-Generate-Unity.run.xml | 20 ++++++ .../TEMPLATE-SDK-OAPI-Generate-Unreal.run.xml | 20 ++++++ ...ATE-SDK-Project-Add-Unreal-Project.run.xml | 20 ++++++ ...MPLATE-SDK-Project-Generate-Client.run.xml | 20 ++++++ ...-SDK-Project-Generate-Ignore-Files.run.xml | 20 ++++++ ...oject-New-Microservice-BeamableDev.run.xml | 20 ++++++ ...Project-New-Microservice-GameMaker.run.xml | 20 ++++++ ...-SDK-Services-Deploy-With-Packages.run.xml | 21 ++++++ cli/.run/TEMPLATE-SDK-Services-Deploy.run.xml | 20 ++++++ .../TEMPLATE-SDK-Services-Ps-Remote.run.xml | 20 ++++++ cli/.run/TEMPLATE-SDK-Services-Ps.run.xml | 20 ++++++ ...ATE-SDK-Services-Run-With-Packages.run.xml | 21 ++++++ cli/.run/TEMPLATE-Set-Local-Packages.run.xml | 17 +++++ .../Project/GenerateEnvFileCommand.cs | 5 +- .../Project/NewMicroserviceCommand.cs | 31 +++++--- .../Services/ServicesDeployCommand.cs | 6 -- .../Commands/Services/ServicesRunCommand.cs | 28 +++----- cli/cli/Services/BeamoLocalSystem_Docker.cs | 14 ++-- .../Services/BeamoLocalSystem_LocalRuntime.cs | 4 +- .../BeamoLocalSystem_RemoteCommunication.cs | 9 +-- ...TO_MAKE_THIS_FOLDER_EXIST_FOR_EVERYONE.txt | 0 client/set-packages.sh => set-packages.sh | 20 +++--- sync-rider-run-settings.sh | 70 +++++++++++++++++++ templates/BeamService/Dockerfile | 14 +--- templates/BeamService/Dockerfile-BeamableDev | 32 +++++++++ 38 files changed, 644 insertions(+), 73 deletions(-) create mode 100644 cli/.run/BEAM-Linux-Cli-Install.run.xml create mode 100644 cli/.run/BEAM-Mac-Cli-Install.run.xml create mode 100644 cli/.run/BEAM-Mac-Sync-Rider-Run-Settings-Unity.run.xml create mode 100644 cli/.run/BEAM-Windows-Cli-Install.run.xml create mode 100644 cli/.run/BEAM-Windows-Sync-Rider-Run-Settings-Unity.run.xml create mode 100644 cli/.run/BEAM-Windows-Sync-Rider-Run-Settings-Unreal.run.xml create mode 100644 cli/.run/TEMPLATE-SDK-Content-Bulk-Edit.run.xml create mode 100644 cli/.run/TEMPLATE-SDK-Content-Publish.run.xml create mode 100644 cli/.run/TEMPLATE-SDK-Content-Pull.run.xml create mode 100644 cli/.run/TEMPLATE-SDK-Content-Reset.run.xml create mode 100644 cli/.run/TEMPLATE-SDK-Content-Status.run.xml create mode 100644 cli/.run/TEMPLATE-SDK-Generate-Interface-CLI-Unreal.run.xml create mode 100644 cli/.run/TEMPLATE-SDK-OAPI-Generate-Unity.run.xml create mode 100644 cli/.run/TEMPLATE-SDK-OAPI-Generate-Unreal.run.xml create mode 100644 cli/.run/TEMPLATE-SDK-Project-Add-Unreal-Project.run.xml create mode 100644 cli/.run/TEMPLATE-SDK-Project-Generate-Client.run.xml create mode 100644 cli/.run/TEMPLATE-SDK-Project-Generate-Ignore-Files.run.xml create mode 100644 cli/.run/TEMPLATE-SDK-Project-New-Microservice-BeamableDev.run.xml create mode 100644 cli/.run/TEMPLATE-SDK-Project-New-Microservice-GameMaker.run.xml create mode 100644 cli/.run/TEMPLATE-SDK-Services-Deploy-With-Packages.run.xml create mode 100644 cli/.run/TEMPLATE-SDK-Services-Deploy.run.xml create mode 100644 cli/.run/TEMPLATE-SDK-Services-Ps-Remote.run.xml create mode 100644 cli/.run/TEMPLATE-SDK-Services-Ps.run.xml create mode 100644 cli/.run/TEMPLATE-SDK-Services-Run-With-Packages.run.xml create mode 100644 cli/.run/TEMPLATE-Set-Local-Packages.run.xml create mode 100644 client/BeamableSource/IM_JUST_HERE_TO_MAKE_THIS_FOLDER_EXIST_FOR_EVERYONE.txt rename client/set-packages.sh => set-packages.sh (57%) mode change 100755 => 100644 create mode 100644 sync-rider-run-settings.sh create mode 100644 templates/BeamService/Dockerfile-BeamableDev diff --git a/.gitignore b/.gitignore index 920eda9af8..fccb4e0722 100644 --- a/.gitignore +++ b/.gitignore @@ -159,3 +159,6 @@ client/Assets/Editor.meta client/Assets/Plugins/Editor.meta client/Assets/Editor/BeamableLoginDev/login_data.json client/Assets/BeamSemiAutomatedTester/Reports +client/BeamableSource/*.nupkg +cli/.run/UNREAL-*.run.xml +cli/.run/UNITY-*.run.xml \ No newline at end of file diff --git a/cli/.run/BEAM-Linux-Cli-Install.run.xml b/cli/.run/BEAM-Linux-Cli-Install.run.xml new file mode 100644 index 0000000000..8e21714bd3 --- /dev/null +++ b/cli/.run/BEAM-Linux-Cli-Install.run.xml @@ -0,0 +1,17 @@ + + + + \ No newline at end of file diff --git a/cli/.run/BEAM-Mac-Cli-Install.run.xml b/cli/.run/BEAM-Mac-Cli-Install.run.xml new file mode 100644 index 0000000000..e73b4b82fa --- /dev/null +++ b/cli/.run/BEAM-Mac-Cli-Install.run.xml @@ -0,0 +1,17 @@ + + + + \ No newline at end of file diff --git a/cli/.run/BEAM-Mac-Sync-Rider-Run-Settings-Unity.run.xml b/cli/.run/BEAM-Mac-Sync-Rider-Run-Settings-Unity.run.xml new file mode 100644 index 0000000000..944243dc78 --- /dev/null +++ b/cli/.run/BEAM-Mac-Sync-Rider-Run-Settings-Unity.run.xml @@ -0,0 +1,17 @@ + + + + \ No newline at end of file diff --git a/cli/.run/BEAM-Windows-Cli-Install.run.xml b/cli/.run/BEAM-Windows-Cli-Install.run.xml new file mode 100644 index 0000000000..44fe3d97c0 --- /dev/null +++ b/cli/.run/BEAM-Windows-Cli-Install.run.xml @@ -0,0 +1,17 @@ + + + + \ No newline at end of file diff --git a/cli/.run/BEAM-Windows-Sync-Rider-Run-Settings-Unity.run.xml b/cli/.run/BEAM-Windows-Sync-Rider-Run-Settings-Unity.run.xml new file mode 100644 index 0000000000..8dbc000ca2 --- /dev/null +++ b/cli/.run/BEAM-Windows-Sync-Rider-Run-Settings-Unity.run.xml @@ -0,0 +1,17 @@ + + + + \ No newline at end of file diff --git a/cli/.run/BEAM-Windows-Sync-Rider-Run-Settings-Unreal.run.xml b/cli/.run/BEAM-Windows-Sync-Rider-Run-Settings-Unreal.run.xml new file mode 100644 index 0000000000..1f5ffa1500 --- /dev/null +++ b/cli/.run/BEAM-Windows-Sync-Rider-Run-Settings-Unreal.run.xml @@ -0,0 +1,17 @@ + + + + \ No newline at end of file diff --git a/cli/.run/TEMPLATE-SDK-Content-Bulk-Edit.run.xml b/cli/.run/TEMPLATE-SDK-Content-Bulk-Edit.run.xml new file mode 100644 index 0000000000..81c89365c1 --- /dev/null +++ b/cli/.run/TEMPLATE-SDK-Content-Bulk-Edit.run.xml @@ -0,0 +1,20 @@ + + + + \ No newline at end of file diff --git a/cli/.run/TEMPLATE-SDK-Content-Publish.run.xml b/cli/.run/TEMPLATE-SDK-Content-Publish.run.xml new file mode 100644 index 0000000000..b82b3634ed --- /dev/null +++ b/cli/.run/TEMPLATE-SDK-Content-Publish.run.xml @@ -0,0 +1,20 @@ + + + + \ No newline at end of file diff --git a/cli/.run/TEMPLATE-SDK-Content-Pull.run.xml b/cli/.run/TEMPLATE-SDK-Content-Pull.run.xml new file mode 100644 index 0000000000..8d82bb2f6a --- /dev/null +++ b/cli/.run/TEMPLATE-SDK-Content-Pull.run.xml @@ -0,0 +1,20 @@ + + + + \ No newline at end of file diff --git a/cli/.run/TEMPLATE-SDK-Content-Reset.run.xml b/cli/.run/TEMPLATE-SDK-Content-Reset.run.xml new file mode 100644 index 0000000000..3b5feb2d99 --- /dev/null +++ b/cli/.run/TEMPLATE-SDK-Content-Reset.run.xml @@ -0,0 +1,20 @@ + + + + \ No newline at end of file diff --git a/cli/.run/TEMPLATE-SDK-Content-Status.run.xml b/cli/.run/TEMPLATE-SDK-Content-Status.run.xml new file mode 100644 index 0000000000..50ee4423ca --- /dev/null +++ b/cli/.run/TEMPLATE-SDK-Content-Status.run.xml @@ -0,0 +1,20 @@ + + + + \ No newline at end of file diff --git a/cli/.run/TEMPLATE-SDK-Generate-Interface-CLI-Unreal.run.xml b/cli/.run/TEMPLATE-SDK-Generate-Interface-CLI-Unreal.run.xml new file mode 100644 index 0000000000..ad93631c80 --- /dev/null +++ b/cli/.run/TEMPLATE-SDK-Generate-Interface-CLI-Unreal.run.xml @@ -0,0 +1,20 @@ + + + + \ No newline at end of file diff --git a/cli/.run/TEMPLATE-SDK-OAPI-Generate-Unity.run.xml b/cli/.run/TEMPLATE-SDK-OAPI-Generate-Unity.run.xml new file mode 100644 index 0000000000..c3918e5bee --- /dev/null +++ b/cli/.run/TEMPLATE-SDK-OAPI-Generate-Unity.run.xml @@ -0,0 +1,20 @@ + + + + \ No newline at end of file diff --git a/cli/.run/TEMPLATE-SDK-OAPI-Generate-Unreal.run.xml b/cli/.run/TEMPLATE-SDK-OAPI-Generate-Unreal.run.xml new file mode 100644 index 0000000000..87415c073c --- /dev/null +++ b/cli/.run/TEMPLATE-SDK-OAPI-Generate-Unreal.run.xml @@ -0,0 +1,20 @@ + + + + \ No newline at end of file diff --git a/cli/.run/TEMPLATE-SDK-Project-Add-Unreal-Project.run.xml b/cli/.run/TEMPLATE-SDK-Project-Add-Unreal-Project.run.xml new file mode 100644 index 0000000000..c787a141fe --- /dev/null +++ b/cli/.run/TEMPLATE-SDK-Project-Add-Unreal-Project.run.xml @@ -0,0 +1,20 @@ + + + + \ No newline at end of file diff --git a/cli/.run/TEMPLATE-SDK-Project-Generate-Client.run.xml b/cli/.run/TEMPLATE-SDK-Project-Generate-Client.run.xml new file mode 100644 index 0000000000..a330cb275a --- /dev/null +++ b/cli/.run/TEMPLATE-SDK-Project-Generate-Client.run.xml @@ -0,0 +1,20 @@ + + + + \ No newline at end of file diff --git a/cli/.run/TEMPLATE-SDK-Project-Generate-Ignore-Files.run.xml b/cli/.run/TEMPLATE-SDK-Project-Generate-Ignore-Files.run.xml new file mode 100644 index 0000000000..aefbddabf9 --- /dev/null +++ b/cli/.run/TEMPLATE-SDK-Project-Generate-Ignore-Files.run.xml @@ -0,0 +1,20 @@ + + + + \ No newline at end of file diff --git a/cli/.run/TEMPLATE-SDK-Project-New-Microservice-BeamableDev.run.xml b/cli/.run/TEMPLATE-SDK-Project-New-Microservice-BeamableDev.run.xml new file mode 100644 index 0000000000..fb9a63b88c --- /dev/null +++ b/cli/.run/TEMPLATE-SDK-Project-New-Microservice-BeamableDev.run.xml @@ -0,0 +1,20 @@ + + + + \ No newline at end of file diff --git a/cli/.run/TEMPLATE-SDK-Project-New-Microservice-GameMaker.run.xml b/cli/.run/TEMPLATE-SDK-Project-New-Microservice-GameMaker.run.xml new file mode 100644 index 0000000000..d30f99bf0d --- /dev/null +++ b/cli/.run/TEMPLATE-SDK-Project-New-Microservice-GameMaker.run.xml @@ -0,0 +1,20 @@ + + + + \ No newline at end of file diff --git a/cli/.run/TEMPLATE-SDK-Services-Deploy-With-Packages.run.xml b/cli/.run/TEMPLATE-SDK-Services-Deploy-With-Packages.run.xml new file mode 100644 index 0000000000..399a8d47e7 --- /dev/null +++ b/cli/.run/TEMPLATE-SDK-Services-Deploy-With-Packages.run.xml @@ -0,0 +1,21 @@ + + + + \ No newline at end of file diff --git a/cli/.run/TEMPLATE-SDK-Services-Deploy.run.xml b/cli/.run/TEMPLATE-SDK-Services-Deploy.run.xml new file mode 100644 index 0000000000..042a859d55 --- /dev/null +++ b/cli/.run/TEMPLATE-SDK-Services-Deploy.run.xml @@ -0,0 +1,20 @@ + + + + \ No newline at end of file diff --git a/cli/.run/TEMPLATE-SDK-Services-Ps-Remote.run.xml b/cli/.run/TEMPLATE-SDK-Services-Ps-Remote.run.xml new file mode 100644 index 0000000000..a2e9fb7ec9 --- /dev/null +++ b/cli/.run/TEMPLATE-SDK-Services-Ps-Remote.run.xml @@ -0,0 +1,20 @@ + + + + \ No newline at end of file diff --git a/cli/.run/TEMPLATE-SDK-Services-Ps.run.xml b/cli/.run/TEMPLATE-SDK-Services-Ps.run.xml new file mode 100644 index 0000000000..c1a01c0043 --- /dev/null +++ b/cli/.run/TEMPLATE-SDK-Services-Ps.run.xml @@ -0,0 +1,20 @@ + + + + \ No newline at end of file diff --git a/cli/.run/TEMPLATE-SDK-Services-Run-With-Packages.run.xml b/cli/.run/TEMPLATE-SDK-Services-Run-With-Packages.run.xml new file mode 100644 index 0000000000..afe2d61ca8 --- /dev/null +++ b/cli/.run/TEMPLATE-SDK-Services-Run-With-Packages.run.xml @@ -0,0 +1,21 @@ + + + + \ No newline at end of file diff --git a/cli/.run/TEMPLATE-Set-Local-Packages.run.xml b/cli/.run/TEMPLATE-Set-Local-Packages.run.xml new file mode 100644 index 0000000000..bea21ba039 --- /dev/null +++ b/cli/.run/TEMPLATE-Set-Local-Packages.run.xml @@ -0,0 +1,17 @@ + + + + \ No newline at end of file diff --git a/cli/cli/Commands/Project/GenerateEnvFileCommand.cs b/cli/cli/Commands/Project/GenerateEnvFileCommand.cs index b4605a9349..67126a31c8 100644 --- a/cli/cli/Commands/Project/GenerateEnvFileCommand.cs +++ b/cli/cli/Commands/Project/GenerateEnvFileCommand.cs @@ -23,7 +23,6 @@ public class GenerateEnvFileCommandArgs : CommandArgs public int instanceCount = 1; public ServiceName serviceId; public bool autoDeploy; - public string buildMode; } public class GenerateEnvFileCommand : AtomicCommand @@ -41,8 +40,6 @@ public override void Configure() AddOption(new Option("--include-prefix", () => true, "If true, the generated .env file will include the local machine name as prefix"), (args, i) => args.includePrefix = i); AddOption(new Option("--instance-count", () => 1, "How many virtual websocket connections the server will open"), (args, i) => args.instanceCount = i); AddOption(new Option("--auto-deploy", () => false, "When enabled, automatically deploy dependencies that aren't running"), (args, i) => args.autoDeploy = i); - AddOption(new Option("--build-mode", () => "game_maker", $"INTERNAL This enables a sane workflow for beamable developers to be happy and productive"), - (args, i) => args.buildMode = i); } public override async Task GetResult(GenerateEnvFileCommandArgs args) @@ -85,7 +82,7 @@ public override async Task GetResult(GenerateEnvFileComma Log.Information("Starting " + string.Join(",", dependencies) + " " + sw.ElapsedMilliseconds); // ImageBuildArgs not needed when deploying only MicroStorages - await args.BeamoLocalSystem.DeployToLocal(args.BeamoLocalSystem, new DockerBuildArgs { BuildMode = args.buildMode, }, dependencies.Select(dep => dep.name).ToArray()); + await args.BeamoLocalSystem.DeployToLocal(args.BeamoLocalSystem, dependencies.Select(dep => dep.name).ToArray()); args.BeamoLocalSystem.SaveBeamoLocalManifest(); args.BeamoLocalSystem.SaveBeamoLocalRuntime(); diff --git a/cli/cli/Commands/Project/NewMicroserviceCommand.cs b/cli/cli/Commands/Project/NewMicroserviceCommand.cs index b238a70c17..78154a2adc 100644 --- a/cli/cli/Commands/Project/NewMicroserviceCommand.cs +++ b/cli/cli/Commands/Project/NewMicroserviceCommand.cs @@ -66,9 +66,7 @@ public static void ConfigureSolutionFlag(AppCommand command) args.SlnFilePath += ".sln"; } } - }); - } /// @@ -100,6 +98,7 @@ public async Promise CreateConfigIfNeeded(InitCommand command) { return; } + if (!AutoInit) { throw CliExceptions.CONFIG_DOES_NOT_EXISTS; @@ -113,14 +112,11 @@ public async Promise CreateConfigIfNeeded(InitCommand command) await command.Handle(initArgs); initArgs.ConfigService.SetTempWorkingDir(oldDir); initArgs.ConfigService.SetBeamableDirectory(this.GetSlnDirectory()); - - } // public void } - public class ServiceNameArgument : Argument { public ServiceNameArgument(string description = "Name of the new project") : base("name", description) { } @@ -129,7 +125,7 @@ public class ServiceNameArgument : Argument public class SpecificVersionOption : Option { public SpecificVersionOption() : base( - name: "--version", + name: "--version", getDefaultValue: () => VersionService.GetNugetPackagesForExecutingCliVersion().ToString(), description: $"Specifies version of Beamable project dependencies. Defaults to the current version of the CLI") { @@ -139,9 +135,9 @@ public class SpecificVersionOption : Option public class NewMicroserviceArgs : SolutionCommandArgs { public bool GenerateCommon; + public bool IsBeamableDev; } - public class RegenerateSolutionFilesCommandArgs : SolutionCommandArgs { public string tempDirectory; @@ -172,6 +168,9 @@ public override void Configure() name: "--generate-common", description: "If passed, will create a common library for this project"), (args, i) => args.GenerateCommon = i); + + AddOption(new Option("--beamable-dev", () => false, $"INTERNAL This enables a sane workflow for beamable developers to be happy and productive"), + (args, i) => args.IsBeamableDev = i); } public override async Task Handle(NewMicroserviceArgs args) @@ -180,17 +179,33 @@ public override async Task Handle(NewMicroserviceArgs args) var newMicroserviceInfo = await args.ProjectService.CreateNewMicroservice(args); + var isBeamableDev = args.IsBeamableDev; var sd = await args.ProjectService.AddDefinitonToNewService(args, newMicroserviceInfo); await args.BeamoLocalSystem.UpdateDockerFile(sd); + var service = args.BeamoLocalSystem.BeamoManifest.HttpMicroserviceLocalProtocols[sd.BeamoId]; if (args.GenerateCommon) { - var service = args.BeamoLocalSystem.BeamoManifest.HttpMicroserviceLocalProtocols[sd.BeamoId]; await args.ProjectService.UpdateDockerFileWithCommonProject(args.ConfigService, args.ProjectName, service.RelativeDockerfilePath, service.DockerBuildContextPath); } + // Make sure we have the correct docker file + var regularDockerfilePath = Path.Combine(service.DockerBuildContextPath, service.RelativeDockerfilePath); + var beamableDevDockerfilePath = regularDockerfilePath + "-BeamableDev"; + if (isBeamableDev) + { + if (File.Exists(beamableDevDockerfilePath)) + { + var beamableDevDockerfileContents = await File.ReadAllTextAsync(beamableDevDockerfilePath); + await File.WriteAllTextAsync(regularDockerfilePath, beamableDevDockerfileContents); + } + } + + // We always delete the -BeamableDev dockerfile from the template. + File.Delete(beamableDevDockerfilePath); + args.BeamoLocalSystem.SaveBeamoLocalManifest(); args.BeamoLocalSystem.SaveBeamoLocalRuntime(); diff --git a/cli/cli/Commands/Services/ServicesDeployCommand.cs b/cli/cli/Commands/Services/ServicesDeployCommand.cs index 64b9a7452e..1c9fc148df 100644 --- a/cli/cli/Commands/Services/ServicesDeployCommand.cs +++ b/cli/cli/Commands/Services/ServicesDeployCommand.cs @@ -19,8 +19,6 @@ public class ServicesDeployCommandArgs : LoginCommandArgs public string FromJsonFile; - public string BuildMode; - public string RemoteComment; public string[] RemoteServiceComments; public string dockerRegistryUrl; @@ -58,9 +56,6 @@ public override void Configure() AddOption(new Option("--comment", () => "", $"Associates this comment along with the published Manifest. You'll be able to read it via the Beamable Portal"), (args, i) => args.RemoteComment = i); - AddOption(new Option("--build-mode", () => "game_maker", $"INTERNAL This enables a sane workflow for beamable developers to be happy and productive"), - (args, i) => args.BuildMode = i); - AddOption(new Option("--service-comments", Array.Empty, $"Any number of strings in the format BeamoId::Comment" + $"\nAssociates each comment to the given Beamo Id if it's among the published services. You'll be able to read it via the Beamable Portal") { @@ -246,7 +241,6 @@ await AnsiConsole _ = await _localBeamo.DeployToRemote(_localBeamo, dockerRegistryUrl, args.RemoteComment ?? string.Empty, perServiceComments, - new DockerBuildArgs() { BuildMode = args.BuildMode, }, (beamoId, progress) => { var progressTask = buildAndTestTasks.FirstOrDefault(pt => pt.Description.Contains(beamoId)); diff --git a/cli/cli/Commands/Services/ServicesRunCommand.cs b/cli/cli/Commands/Services/ServicesRunCommand.cs index 84c5dc55c7..91d8600368 100644 --- a/cli/cli/Commands/Services/ServicesRunCommand.cs +++ b/cli/cli/Commands/Services/ServicesRunCommand.cs @@ -16,7 +16,6 @@ public class ServicesRunCommandArgs : LoginCommandArgs { public string[] BeamoIdsToDeploy; public bool forceAmdCpuArchitecture = false; - public string BuildMode; } public class ServicesRunCommand : AppCommand, @@ -40,9 +39,6 @@ public override void Configure() new Option(new string[] { "--force-amd-cpu-arch", "-fcpu" }, () => false, "Force the services to run with amd64 CPU architecture, useful when deploying from computers with ARM architecture"), (args, i) => args.forceAmdCpuArchitecture = i); - - AddOption(new Option("--build-mode", () => "game_maker", $"INTERNAL This enables a sane workflow for beamable developers to be happy and productive"), - (args, i) => args.BuildMode = i); } public override async Task Handle(ServicesRunCommandArgs args) @@ -123,19 +119,17 @@ await AnsiConsole var sequence = Promise.Sequence(promises); await sequence; - await _localBeamo.DeployToLocal(_localBeamo, new DockerBuildArgs() { BuildMode = args.BuildMode }, uniqueIds, - args.forceAmdCpuArchitecture, - (beamoId, progress) => - { - var progressTask = allProgressTasks.FirstOrDefault(pt => pt.Description.Contains(beamoId)); - progressTask?.Increment((progress * 80) - progressTask.Value); - this.SendResults(new ServiceRunProgressResult() { BeamoId = beamoId, LocalDeployProgress = progressTask?.Value ?? 0.0f, }); - }, beamoId => - { - var progressTask = allProgressTasks.FirstOrDefault(pt => pt.Description.Contains(beamoId)); - progressTask?.Increment(20); - this.SendResults(new ServiceRunProgressResult() { BeamoId = beamoId, LocalDeployProgress = progressTask?.Value ?? 0.0f, }); - }); + await _localBeamo.DeployToLocal(_localBeamo, uniqueIds, args.forceAmdCpuArchitecture, (beamoId, progress) => + { + var progressTask = allProgressTasks.FirstOrDefault(pt => pt.Description.Contains(beamoId)); + progressTask?.Increment((progress * 80) - progressTask.Value); + this.SendResults(new ServiceRunProgressResult() { BeamoId = beamoId, LocalDeployProgress = progressTask?.Value ?? 0.0f, }); + }, beamoId => + { + var progressTask = allProgressTasks.FirstOrDefault(pt => pt.Description.Contains(beamoId)); + progressTask?.Increment(20); + this.SendResults(new ServiceRunProgressResult() { BeamoId = beamoId, LocalDeployProgress = progressTask?.Value ?? 0.0f, }); + }); } catch (CliException e) { diff --git a/cli/cli/Services/BeamoLocalSystem_Docker.cs b/cli/cli/Services/BeamoLocalSystem_Docker.cs index 1055ecf70f..68f96031d9 100644 --- a/cli/cli/Services/BeamoLocalSystem_Docker.cs +++ b/cli/cli/Services/BeamoLocalSystem_Docker.cs @@ -174,7 +174,7 @@ public async Task RunContainer(string containerId) /// and . /// /// The image id that was created/pulled. - public async Task PrepareBeamoServiceImage(BeamoServiceDefinition serviceDefinition, DockerBuildArgs imageBuildArgs, Action messageHandler, bool forceAmdCpuArchitecture = false) + public async Task PrepareBeamoServiceImage(BeamoServiceDefinition serviceDefinition, Action messageHandler, bool forceAmdCpuArchitecture = false) { switch (serviceDefinition.Protocol) { @@ -193,7 +193,6 @@ public async Task PrepareBeamoServiceImage(BeamoServiceDefinition servic serviceDefinition.ImageId = await BuildAndCreateImage(serviceDefinition.BeamoId.ToLower(), localProtocol.DockerBuildContextPath, localProtocol.RelativeDockerfilePath, - imageBuildArgs, progress => { messageHandler?.Invoke(serviceDefinition.BeamoId, progress); @@ -212,7 +211,7 @@ public async Task PrepareBeamoServiceImage(BeamoServiceDefinition servic /// Builds an image with the local docker engine using the given , and dockerfile (). /// It inspects the created image and returns it's ID. /// - public async Task BuildAndCreateImage(string imageName, string dockerBuildContextPath, string dockerfilePathInBuildContext, DockerBuildArgs imageBuildArgs, Action progressUpdateHandler, + public async Task BuildAndCreateImage(string imageName, string dockerBuildContextPath, string dockerfilePathInBuildContext, Action progressUpdateHandler, string containerImageTag = "latest", bool forceAmdCpuArchitecture = false) { @@ -231,7 +230,6 @@ public async Task PrepareBeamoServiceImage(BeamoServiceDefinition servic Dockerfile = dockerfilePathInBuildContext.Replace("\\", "/"), Labels = new Dictionary() { { "beamoId", imageName } }, Pull = "pull", - BuildArgs = new Dictionary { { "BUILD_MODE", imageBuildArgs.BuildMode } } }; if (forceAmdCpuArchitecture) { @@ -334,9 +332,7 @@ private static List ParseDockerfile(ConfigService configService, string { // Handles escaping stuff from copy statements that we don't need (to enforce pattern of COPY SOURCE DESTINATION). string escapedLine = line; - if (escapedLine.StartsWith("ONBUILD COPY")) - escapedLine = escapedLine.Replace("ONBUILD ", ""); - + //This needs to have the follow pattern: "COPY SOURCE DESTINATION", if not just continues reading file if (escapedLine.Contains("--")) escapedLine = ""; @@ -345,6 +341,10 @@ private static List ParseDockerfile(ConfigService configService, string { var parts = escapedLine.Split(" ", StringSplitOptions.RemoveEmptyEntries); var probablePath = parts[1]; + + if (probablePath.Contains("*")) + probablePath = Path.GetDirectoryName(probablePath); + try { var result = Path.GetFullPath(configService.BeamableRelativeToExecutionRelative(probablePath)); diff --git a/cli/cli/Services/BeamoLocalSystem_LocalRuntime.cs b/cli/cli/Services/BeamoLocalSystem_LocalRuntime.cs index 705953621e..44ba5d0a23 100644 --- a/cli/cli/Services/BeamoLocalSystem_LocalRuntime.cs +++ b/cli/cli/Services/BeamoLocalSystem_LocalRuntime.cs @@ -345,7 +345,7 @@ private bool VerifyCanBeBuiltLocally(BeamoLocalManifest manifest, BeamoServiceDe /// Using the given , builds and deploys all services with the given to the local docker engine. /// If is null, will deploy ALL services. Also, this does check for cyclical dependencies before running the deployment. /// - public async Task DeployToLocal(BeamoLocalSystem localSystem, DockerBuildArgs imageBuildArgs, string[] deployBeamoIds = null, + public async Task DeployToLocal(BeamoLocalSystem localSystem, string[] deployBeamoIds = null, bool forceAmdCpuArchitecture = false, Action buildPullImageProgress = null, Action onServiceDeployCompleted = null) { @@ -372,7 +372,7 @@ private bool VerifyCanBeBuiltLocally(BeamoLocalManifest manifest, BeamoServiceDe // Builds all images for all services that are defined and can be built locally. - var prepareImages = new List(serviceDefinitionsToDeploy.Select(c => PrepareBeamoServiceImage(c, imageBuildArgs, buildPullImageProgress, forceAmdCpuArchitecture))); + var prepareImages = new List(serviceDefinitionsToDeploy.Select(c => PrepareBeamoServiceImage(c, buildPullImageProgress, forceAmdCpuArchitecture))); await Task.WhenAll(prepareImages); // Build dependency layers split by protocol type. diff --git a/cli/cli/Services/BeamoLocalSystem_RemoteCommunication.cs b/cli/cli/Services/BeamoLocalSystem_RemoteCommunication.cs index cadb6ab32c..8345bc2de1 100644 --- a/cli/cli/Services/BeamoLocalSystem_RemoteCommunication.cs +++ b/cli/cli/Services/BeamoLocalSystem_RemoteCommunication.cs @@ -71,7 +71,7 @@ public async Task SyncLocalManifestWithRemote(ServiceManifest remoteManifest) /// Deploys services defined in the given . /// public async Task DeployToRemote(BeamoLocalSystem localSystem, string dockerRegistryUrl, string comments, - Dictionary perServiceComments, DockerBuildArgs imageBuildArgs, Action buildPullImageProgress = null, Action onServiceDeployCompleted = null, + Dictionary perServiceComments, Action buildPullImageProgress = null, Action onServiceDeployCompleted = null, Action onContainerUploadProgress = null, Action onContainerUploadCompleted = null) { BeamoLocalManifest localManifest = localSystem.BeamoManifest; @@ -82,7 +82,7 @@ public async Task SyncLocalManifestWithRemote(ServiceManifest remoteManifest) // Then, let's try to deploy locally first. try { - await DeployToLocal(localSystem, imageBuildArgs, null, true, buildPullImageProgress, onServiceDeployCompleted); + await DeployToLocal(localSystem, null, true, buildPullImageProgress, onServiceDeployCompleted); } // If we fail, log out a message and the exception that caused the failure catch (Exception e) @@ -638,8 +638,3 @@ private struct FileBlobResult #endregion } - -public struct DockerBuildArgs -{ - public string BuildMode; -} diff --git a/client/BeamableSource/IM_JUST_HERE_TO_MAKE_THIS_FOLDER_EXIST_FOR_EVERYONE.txt b/client/BeamableSource/IM_JUST_HERE_TO_MAKE_THIS_FOLDER_EXIST_FOR_EVERYONE.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/client/set-packages.sh b/set-packages.sh old mode 100755 new mode 100644 similarity index 57% rename from client/set-packages.sh rename to set-packages.sh index 6f4cd60ab4..8201b0ae8c --- a/client/set-packages.sh +++ b/set-packages.sh @@ -1,4 +1,6 @@ -PROJECTS_DIR=${PROJECT_DIR_OVERRIDE:-"../ProjectsSource"} +#!/bin/bash + +PROJECTS_DIR=${PROJECT_DIR_OVERRIDE:-"ProjectsSource"} HOME_FOR_BUILD=${1:-$HOME} PROJECTS_SOURCE="$HOME_FOR_BUILD/BeamableSource/" SOURCE_NAME="BeamableSource" @@ -24,17 +26,17 @@ else fi echo "Creating nupckg files for our packages" -dotnet pack ../cli/beamable.common/ --configuration Release --include-source -o $PROJECTS_DIR -p:PackageVersion=$VERSION -p:InformationalVersion=$VERSION_INFO -dotnet pack ../cli/beamable.server.common/ --configuration Release --include-source -o $PROJECTS_DIR -p:PackageVersion=$VERSION -p:InformationalVersion=$VERSION_INFO -dotnet pack ../microservice/beamable.tooling.common/ --configuration Release --include-source -o $PROJECTS_DIR -p:PackageVersion=$VERSION -p:InformationalVersion=$VERSION_INFO -dotnet pack ../microservice/unityEngineStubs/ --configuration Release --include-source -o $PROJECTS_DIR -p:PackageVersion=$VERSION -p:InformationalVersion=$VERSION_INFO -dotnet pack ../microservice/unityEngineStubs.addressables/ --configuration Release --include-source -o $PROJECTS_DIR -p:PackageVersion=$VERSION -p:InformationalVersion=$VERSION_INFO +dotnet pack ./cli/beamable.common/ --configuration Release --include-source -o $PROJECTS_DIR -p:PackageVersion=$VERSION -p:InformationalVersion=$VERSION_INFO +dotnet pack ./cli/beamable.server.common/ --configuration Release --include-source -o $PROJECTS_DIR -p:PackageVersion=$VERSION -p:InformationalVersion=$VERSION_INFO +dotnet pack ./microservice/beamable.tooling.common/ --configuration Release --include-source -o $PROJECTS_DIR -p:PackageVersion=$VERSION -p:InformationalVersion=$VERSION_INFO +dotnet pack ./microservice/unityEngineStubs/ --configuration Release --include-source -o $PROJECTS_DIR -p:PackageVersion=$VERSION -p:InformationalVersion=$VERSION_INFO +dotnet pack ./microservice/unityEngineStubs.addressables/ --configuration Release --include-source -o $PROJECTS_DIR -p:PackageVersion=$VERSION -p:InformationalVersion=$VERSION_INFO -dotnet build ../microservice/microservice/ --configuration Release -p:PackageVersion=$VERSION -p:CombinedVersion=$VERSION -p:InformationalVersion=$VERSION_INFO -dotnet pack ../microservice/microservice/ --configuration Release --no-build --include-source -o $PROJECTS_DIR -p:PackageVersion=$VERSION -p:CombinedVersion=$VERSION -p:InformationalVersion=$VERSION_INFO +dotnet build ./microservice/microservice/ --configuration Release -p:PackageVersion=$VERSION -p:CombinedVersion=$VERSION -p:InformationalVersion=$VERSION_INFO +dotnet pack ./microservice/microservice/ --configuration Release --no-build --include-source -o $PROJECTS_DIR -p:PackageVersion=$VERSION -p:CombinedVersion=$VERSION -p:InformationalVersion=$VERSION_INFO -OUTPUT=$PROJECTS_DIR VERSION=$VERSION ../templates/build.sh +OUTPUT=$PROJECTS_DIR VERSION=$VERSION ./templates/build.sh if dotnet nuget list source | grep -q $SOURCE_NAME; then echo "Source already exists!" diff --git a/sync-rider-run-settings.sh b/sync-rider-run-settings.sh new file mode 100644 index 0000000000..32d4c79feb --- /dev/null +++ b/sync-rider-run-settings.sh @@ -0,0 +1,70 @@ +#!/bin/sh + +BASEDIR=$(dirname "$0") +echo "$BASEDIR" + +TargetEngine="$1" + +# For unity, this defaults to /client, but can be overridable +PathToWorkingDirectory="$2" +if [[ $TargetEngine == "UNITY" && $PathToWorkingDirectory == "" ]]; then + PathToWorkingDirectory="$BASEDIR/client" +fi +PathToWorkingDirectory="${PathToWorkingDirectory//\\/\/}" + +# This argument is the path to GitBash 99% of the time. If not given, assumes C:/Program Files/Git/bin/bash.exe +PathToUnixShell="$3" +if [[ $PathToUnixShell == "" ]]; then + case "$OSTYPE" in + solaris*) echo "/bin/bash" ;; + darwin*) echo "/bin/bash" ;; + linux*) echo "/usr/bin/bash" ;; + bsd*) echo "/usr/bin/bash" ;; + msys*) PathToUnixShell="C:\Program Files\Git\bin\bash.exe" ;; + cygwin*) PathToUnixShell="C:\Program Files\Git\bin\bash.exe" ;; + *) echo "Should never see this!!" ;; + esac + +fi +PathToUnixShell="${PathToUnixShell//\\/\/}" + +# Path to the CLI .run folder. +CliRunPath="$BASEDIR/cli/.run" + +if [ -d "$CliRunPath" ]; then + echo "Copying all TEMPLATE- configurations into $TargetEngine- configurations." + + for i in $(find "$CliRunPath" -name 'TEMPLATE-*.run.xml'); do # Not recommended, will break on whitespace + + TargetFile="${i/TEMPLATE-/"$TargetEngine"-}" + echo "cp -u $i $TargetFile" + cp -u "$i" "$TargetFile" + echo sed -i 's/TEMPLATE-/'"$TargetEngine"'-/g' "$TargetFile" + sed -i 's/TEMPLATE-/'"$TargetEngine"'-/g' "$TargetFile" + + # If there is an INTERPRETER_PATH in the xml, replace it with the given $PathToUnixShell + echo sed -i '\@="INTERPRETER_PATH"@s@value=".*"@value="'"$PathToUnixShell"'"@g' "$TargetFile" + sed -i '\@="INTERPRETER_PATH"@s@value=".*"@value="'"$PathToUnixShell"'"@g' "$TargetFile" + + # For the local packages script we also change the SCRIPT_OPTIONS to point to the $PathToWorkingDirectory + # For every other script, we set the WORKING_DIRECTORY path in the xml, replace it with the given $PathToWorkingDirectory + if [[ $TargetFile == *$TargetEngine-Set-Local-Packages* ]]; then + echo sed -i '\@="SCRIPT_OPTIONS"@s@value=".*"@value="'"$PathToWorkingDirectory"'"@g' "$TargetFile" + sed -i '\@="SCRIPT_OPTIONS"@s@value=".*"@value="'"$PathToWorkingDirectory"'"@g' "$TargetFile" + continue + else + echo sed -i '\@="WORKING_DIRECTORY"@s@value=".*"@value="'"$PathToWorkingDirectory"'"@g' "$TargetFile" + sed -i '\@="WORKING_DIRECTORY"@s@value=".*"@value="'"$PathToWorkingDirectory"'"@g' "$TargetFile" + fi + done + +else + echo "Invalid path to a .run folder. Given Path: $CliRunPath" +fi + + + + + + + diff --git a/templates/BeamService/Dockerfile b/templates/BeamService/Dockerfile index 074521962b..e0f5c64be9 100644 --- a/templates/BeamService/Dockerfile +++ b/templates/BeamService/Dockerfile @@ -1,19 +1,7 @@ ARG BUILD_MODE=beamable_dev # Processes specific -FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine as build_game_maker -ONBUILD RUN echo "Making a game-maker build" - -FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine as build_beamable_dev -ONBUILD COPY ./BeamableSource ./BeamableSource -ONBUILD RUN dotnet nuget add source ./BeamableSource - -# use the dotnet SDK as a build stage -FROM build_${BUILD_MODE} as build-env - -# Since generating the common library is optional, the CLI will replace the insert flag below to copy it correctly -# At the moment, it'll only do so, if the common library project was created at the time of setting up the solution. -# If not, this line will remain so that we can make a command that adds only the common library to your C#MS solution. +FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine as build-env # this line signals the start of Beamable Project Src copies into the built container. Do not remove it. The content between here and the closing tag will change anytime the Beam CLI modifies dependencies. diff --git a/templates/BeamService/Dockerfile-BeamableDev b/templates/BeamService/Dockerfile-BeamableDev new file mode 100644 index 0000000000..a9788f24e7 --- /dev/null +++ b/templates/BeamService/Dockerfile-BeamableDev @@ -0,0 +1,32 @@ +# Processes specific + +FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine as build-env +WORKDIR /BeamableSource +COPY ./BeamableSource/*.nupkg ./ +WORKDIR /subsrc/ +RUN dotnet nuget add source /BeamableSource + +# this line signals the start of Beamable Project Src copies into the built container. Do not remove it. The content between here and the closing tag will change anytime the Beam CLI modifies dependencies. + +# this line signals the end of Beamable Project Src copies. Do not remove it. + +# build the dotnet program +WORKDIR / +RUN dotnet publish /subsrc/BeamService/BeamService.csproj -c release -o /subapp + +# use the dotnet runtime as the final stage +FROM mcr.microsoft.com/dotnet/runtime:6.0-alpine +WORKDIR /subapp + +# expose the health port +EXPOSE 6565 + +# copy the built program +COPY --from=build-env /subapp . + +# when starting the container, run dotnet with the built dll +ENTRYPOINT ["dotnet", "/subapp/BeamService.dll"] + +# Swap entrypoints if the container is exploding and you want to keep it alive indefinitely so you can go look into it. +#ENTRYPOINT ["tail", "-f", "/dev/null"] + From 566573593455cddf8b0082187125167e6da906c3 Mon Sep 17 00:00:00 2001 From: Pedro Rauiz Estigarribia Gestal Date: Mon, 20 May 2024 20:10:48 -0300 Subject: [PATCH 2/5] fixed issue with Unreal Microservice Client codegen's Build.cs file --- cli/cli/Commands/Project/GenerateClientFileCommand.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cli/cli/Commands/Project/GenerateClientFileCommand.cs b/cli/cli/Commands/Project/GenerateClientFileCommand.cs index 5c51650277..fcb82e1d2a 100644 --- a/cli/cli/Commands/Project/GenerateClientFileCommand.cs +++ b/cli/cli/Commands/Project/GenerateClientFileCommand.cs @@ -303,7 +303,10 @@ public class {unrealProjectData.CoreProjectName} : ModuleRules {{ ""Core"", ""BeamableCore"", - ""BeamableCoreRuntime"" + ""BeamableCoreRuntime"", + + ""Json"", + ""JsonUtilities"", }}); From 1a07c37a6895c07acf5b48a7b539876cf8e10d68 Mon Sep 17 00:00:00 2001 From: Pedro Rauiz Estigarribia Gestal Date: Tue, 21 May 2024 09:36:15 -0300 Subject: [PATCH 3/5] updated buildPR workflow to find set-packages.sh in new location --- .github/workflows/buildPR.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/buildPR.yml b/.github/workflows/buildPR.yml index a41df736d2..3598a5e592 100644 --- a/.github/workflows/buildPR.yml +++ b/.github/workflows/buildPR.yml @@ -100,7 +100,7 @@ jobs: restore-keys: | ${{ runner.os }}-nuget - name: Install local packages - working-directory: ./client + working-directory: ./ shell: bash run: | ./set-packages.sh "${{ github.workspace }}" From 49cda582ffab377e85d4c984544b28929d1badfd Mon Sep 17 00:00:00 2001 From: Chris Hanna Date: Tue, 21 May 2024 09:19:23 -0400 Subject: [PATCH 4/5] permissions nonsense --- set-packages.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 set-packages.sh diff --git a/set-packages.sh b/set-packages.sh old mode 100644 new mode 100755 From 597f571eadb5598476ac1d93f13e4f0d438f297d Mon Sep 17 00:00:00 2001 From: Pedro Rauiz Estigarribia Gestal Date: Tue, 21 May 2024 14:47:39 -0300 Subject: [PATCH 5/5] fix issue that would make it impossible to create microservices with the new CLI version but an older template. --- cli/cli/Commands/Project/NewMicroserviceCommand.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cli/cli/Commands/Project/NewMicroserviceCommand.cs b/cli/cli/Commands/Project/NewMicroserviceCommand.cs index 78154a2adc..a1cacbd292 100644 --- a/cli/cli/Commands/Project/NewMicroserviceCommand.cs +++ b/cli/cli/Commands/Project/NewMicroserviceCommand.cs @@ -194,17 +194,17 @@ public override async Task Handle(NewMicroserviceArgs args) // Make sure we have the correct docker file var regularDockerfilePath = Path.Combine(service.DockerBuildContextPath, service.RelativeDockerfilePath); var beamableDevDockerfilePath = regularDockerfilePath + "-BeamableDev"; - if (isBeamableDev) + if (File.Exists(beamableDevDockerfilePath)) { - if (File.Exists(beamableDevDockerfilePath)) + if (isBeamableDev) { var beamableDevDockerfileContents = await File.ReadAllTextAsync(beamableDevDockerfilePath); await File.WriteAllTextAsync(regularDockerfilePath, beamableDevDockerfileContents); } - } - // We always delete the -BeamableDev dockerfile from the template. - File.Delete(beamableDevDockerfilePath); + // We always delete the -BeamableDev dockerfile from the template (for older versions of the template, this file does not exist so... we need to check for it). + File.Delete(beamableDevDockerfilePath); + } args.BeamoLocalSystem.SaveBeamoLocalManifest(); args.BeamoLocalSystem.SaveBeamoLocalRuntime();