-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged in feature/MTM-28374-Example-CS-Microservice (pull request #13)
MTM-28374 Implement and document use cases employing the c#-based microservice Approved-by: Rahul Miryala <rahul.miryala@softwareag.com> Approved-by: Özge Akin <ozge.akin@cumulocity.com> Approved-by: Manasés Galindo <manases.galindo@cumulocity.com>
- Loading branch information
Showing
25 changed files
with
2,108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...icroserviceSDK/Hello-World-Extension-Microservice/DeviceTemperature/DeviceTemperature.sln
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 15 | ||
VisualStudioVersion = 15.0.26124.0 | ||
MinimumVisualStudioVersion = 15.0.26124.0 | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{DF77DEC0-2438-4D0E-B220-1AA721C29BD3}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeviceMicroservice", "src\DeviceMicroservice\DeviceMicroservice.csproj", "{2037579D-FA21-4732-B5B0-23101B7F4240}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Debug|x64 = Debug|x64 | ||
Debug|x86 = Debug|x86 | ||
Release|Any CPU = Release|Any CPU | ||
Release|x64 = Release|x64 | ||
Release|x86 = Release|x86 | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{2037579D-FA21-4732-B5B0-23101B7F4240}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{2037579D-FA21-4732-B5B0-23101B7F4240}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{2037579D-FA21-4732-B5B0-23101B7F4240}.Debug|x64.ActiveCfg = Debug|Any CPU | ||
{2037579D-FA21-4732-B5B0-23101B7F4240}.Debug|x64.Build.0 = Debug|Any CPU | ||
{2037579D-FA21-4732-B5B0-23101B7F4240}.Debug|x86.ActiveCfg = Debug|Any CPU | ||
{2037579D-FA21-4732-B5B0-23101B7F4240}.Debug|x86.Build.0 = Debug|Any CPU | ||
{2037579D-FA21-4732-B5B0-23101B7F4240}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{2037579D-FA21-4732-B5B0-23101B7F4240}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{2037579D-FA21-4732-B5B0-23101B7F4240}.Release|x64.ActiveCfg = Release|Any CPU | ||
{2037579D-FA21-4732-B5B0-23101B7F4240}.Release|x64.Build.0 = Release|Any CPU | ||
{2037579D-FA21-4732-B5B0-23101B7F4240}.Release|x86.ActiveCfg = Release|Any CPU | ||
{2037579D-FA21-4732-B5B0-23101B7F4240}.Release|x86.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(NestedProjects) = preSolution | ||
{2037579D-FA21-4732-B5B0-23101B7F4240} = {DF77DEC0-2438-4D0E-B220-1AA721C29BD3} | ||
EndGlobalSection | ||
EndGlobal |
13 changes: 13 additions & 0 deletions
13
Examples/MicroserviceSDK/Hello-World-Extension-Microservice/DeviceTemperature/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS runtime | ||
WORKDIR /app | ||
COPY ./publish/Web ./ | ||
|
||
#ENV SERVER_PORT 4700 | ||
#ENV C8Y_BASEURL "http://baseurl" | ||
#ENV C8Y_BOOTSTRAP_TENANT "tenant" | ||
#ENV C8Y_BOOTSTRAP_USERNAME "username" | ||
#ENV C8Y_BOOTSTRAP_PASSWORD "password" | ||
#ENV C8Y_MICROSERIVCE_ISOLATION "PER_TENANT" | ||
|
||
ENTRYPOINT ["dotnet", "DeviceMicroservice.dll"] | ||
|
130 changes: 130 additions & 0 deletions
130
Examples/MicroserviceSDK/Hello-World-Extension-Microservice/DeviceTemperature/build.cake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
#addin nuget:https://www.nuget.org/api/v2/?package=cake.docker&version=0.11.0 | ||
|
||
|
||
using Path = System.IO.Path; | ||
using IO = System.IO; | ||
|
||
////////////////////////////////////////////////////////////////////// | ||
// ARGUMENTS | ||
////////////////////////////////////////////////////////////////////// | ||
|
||
var target = Argument("target", "Default"); | ||
var configuration = Argument("configuration", "Release"); | ||
|
||
////////////////////////////////////////////////////////////////////// | ||
// GLOBAL VARIABLES | ||
////////////////////////////////////////////////////////////////////// | ||
|
||
var projectName = "DeviceMicroservice"; | ||
var binaryDir = Directory("./src/"+ projectName +"/bin"); | ||
var objectDir = Directory("./src/"+ projectName +"/obj"); | ||
var projectFile = "./src/"+ projectName +"/"+ projectName +".csproj"; | ||
var publishDir = "./publish"; | ||
var webProject = "./src/"+ projectName +""; | ||
var imageName = ""+ projectName +":latest"; | ||
imageName = imageName.ToLowerInvariant(); | ||
|
||
////////////////////////////////////////////////////////////////////// | ||
// PRIVATE TASKS | ||
////////////////////////////////////////////////////////////////////// | ||
|
||
|
||
Task("Clean") | ||
.Does(() => | ||
{ | ||
CleanDirectory(binaryDir); | ||
CleanDirectory(objectDir); | ||
CleanDirectory(publishDir); | ||
if (FileExists("./images/single/image.tar")){ | ||
DeleteFile("./images/single/image.tar"); | ||
} | ||
if (FileExists("./images/single/image.zip")){ | ||
DeleteFile("./images/single/image.zip"); | ||
} | ||
if (FileExists("./images/multi/image.tar")){ | ||
DeleteFile("./images/multi/image.tar"); | ||
} | ||
if (FileExists("./images/multi/image.zip")){ | ||
DeleteFile("./images/multi/image.zip"); | ||
} | ||
if (FileExists("./image.zip")){ | ||
DeleteFile("./image.zip"); | ||
} | ||
}); | ||
|
||
Task("Build") | ||
.IsDependentOn("Clean") | ||
.Does(()=>{ | ||
DotNetCoreRestore(projectFile); | ||
DotNetCoreBuild(projectFile, new DotNetCoreBuildSettings | ||
{ | ||
Configuration = configuration | ||
}); | ||
//MSBuild(projectFile); | ||
}); | ||
|
||
Task("DotnetPublish") | ||
.IsDependentOn("Clean") | ||
.Does(() => | ||
{ | ||
DotNetCorePublish(webProject, new DotNetCorePublishSettings | ||
{ | ||
Configuration = configuration, | ||
OutputDirectory = Path.Combine(publishDir, "Web") | ||
}); | ||
}); | ||
|
||
Task("Docker-Build") | ||
.IsDependentOn("DotnetPublish") | ||
.Does(() => { | ||
var buildSettings = new DockerImageBuildSettings { Tag = new[] {imageName}}; | ||
DockerBuild(buildSettings, "./"); | ||
var saveSettingsMulti = new DockerImageSaveSettings { Output = "./images/multi/image.tar" }; | ||
DockerSave(saveSettingsMulti,new[] {imageName}); | ||
var filesMulti = new [] { | ||
"./images/multi/image.tar", | ||
"./images/multi/cumulocity.json" }; | ||
Zip("./images/multi", "image.zip", filesMulti); | ||
CopyFileToDirectory("image.zip", "./images/multi"); | ||
if (FileExists("./image.zip")) | ||
{ | ||
DeleteFile("./image.zip"); | ||
} | ||
}); | ||
|
||
Task("Single-DockerImage") | ||
.Does(() => { | ||
var saveSettingsSingle = new DockerImageSaveSettings { Output = "images/single/image.tar" }; | ||
DockerSave(saveSettingsSingle,new[] {imageName}); | ||
var filesSingle = new [] { | ||
"./images/single/image.tar", | ||
"./images/single/cumulocity.json" }; | ||
Zip("./images/single", "image.zip", filesSingle); | ||
CopyFileToDirectory("image.zip", "./images/single"); | ||
}); | ||
|
||
Task("Docker-Run") | ||
.Does(() => { | ||
DockerRun("-p 8999:4700 "+ imageName, "", ""); | ||
}); | ||
|
||
////////////////////////////////////////////////////////////////////// | ||
// TASKS | ||
////////////////////////////////////////////////////////////////////// | ||
|
||
Task("Default") | ||
.IsDependentOn("Docker-Build"); | ||
|
||
////////////////////////////////////////////////////////////////////// | ||
// EXECUTION | ||
////////////////////////////////////////////////////////////////////// | ||
|
||
RunTarget(target); |
Oops, something went wrong.