Using Docker to help soothe the transition to .NET Core

Using Docker to help soothe the transition to .NET Core

Have you heard about this new .NET Core thing? Of course you have. Now are you ready to jump on and get you app or library ported to this new exciting technology? The journey to .Net Core has not always been straight forward and for a traditional Windows based developer this process can be a little daunting. You want to ensure your apps and libraries behave cross platform. How do you build this stuff? How can you gain confidence what your developing is truly cross platform and working as expected? In this lightning talk, Matthew will demonstrate how Docker was used when porting the popular logging library Serilog to .Net Core. Hopefully you will take away some tips to make your transition smoother.

Presented at NDC Sydney

https://serilog.net/
https://github.com/serilog/
https://github.com/serilog/serilog-docker

C4c74e5212f470baa1abe68d8e4fff45?s=128

Matthew Erbs

August 04, 2016
Tweet

Transcript

  1. Using Docker to help soothe the transition to .NET Core

    © The Tiny Tech Company 2016 | github/merbla | @matthewerbs | #ndcsydney 1
  2. .Net Core © Sergey Krivkoc (noun project) © The Tiny

    Tech Company 2016 | github/merbla | @matthewerbs | #ndcsydney 2
  3. G'day I'm Matthew © The Tiny Tech Company 2016 |

    github/merbla | @matthewerbs | #ndcsydney 3
  4. Serilog © The Tiny Tech Company 2016 | github/merbla |

    @matthewerbs | #ndcsydney 4
  5. Hello Serilog! var logger = new LoggerConfiguration() .WriteTo.LiterateConsole() .CreateLogger(); var

    developer = new { Name = "Ramona" }; var position = new { Latitude = 25, Longitude = 134 }; var transaction = new { Id = Guid.NewGuid() }; var elapsedMs = 34; log.Information("Hello NDC Sydney! from {name}", developer.Name); log.Information("Processed {transaction} : {@Position} in {Elapsed:000} ms.", transaction, position, elapsedMs); Output [16:56:28 INF] Hello NDC Sydney! from Ramona [16:56:28 INF] Processed { Id = xxxx-xxx-xxxx-xxxx-xxxx } : {Latitude=25, Longitude=134} in 034 ms. © The Tiny Tech Company 2016 | github/merbla | @matthewerbs | #ndcsydney 5
  6. Some quick stats... • ~ 650,000 downloads (core library) •

    50+ GitHub Repos • Numerous NuGet Packages • Many sinks, extensions and contribution projects • First class .Net Core/ASP.Net integration © The Tiny Tech Company 2016 | github/merbla | @matthewerbs | #ndcsydney 6
  7. .Net Core a long and winding road.... © Sergey Krivkoc

    (noun project) © The Tiny Tech Company 2016 | github/merbla | @matthewerbs | #ndcsydney 7
  8. Challenge A: New Libraries/SDKs & Tooling © The Tiny Tech

    Company 2016 | github/merbla | @matthewerbs | #ndcsydney 8
  9. The Great Beta/RC Churn of 2016 © The Tiny Tech

    Company 2016 | github/merbla | @matthewerbs | #ndcsydney 9
  10. The cheese was moving! { "message" : "Good bye", "features"

    : [ "dnx", "dnu", "dnvm", "project.json", ] } © The Tiny Tech Company 2016 | github/merbla | @matthewerbs | #ndcsydney 10
  11. Challenge B: Cross Platform © The Tiny Tech Company 2016

    | github/merbla | @matthewerbs | #ndcsydney 11
  12. Cross Platform... The Holy Grail © The Tiny Tech Company

    2016 | github/merbla | @matthewerbs | #ndcsydney 12
  13. It's OK, I run a Mac! — Hipster .Net Developer

    © The Tiny Tech Company 2016 | github/merbla | @matthewerbs | #ndcsydney 13
  14. © The Tiny Tech Company 2016 | github/merbla | @matthewerbs

    | #ndcsydney 14
  15. Docker © The Tiny Tech Company 2016 | github/merbla |

    @matthewerbs | #ndcsydney 15
  16. SCALE © The Tiny Tech Company 2016 | github/merbla |

    @matthewerbs | #ndcsydney 16
  17. Isolation & Immutability © The Tiny Tech Company 2016 |

    github/merbla | @matthewerbs | #ndcsydney 17
  18. Library Isolation { ... "dependencies": { "x.x.x": "1.2.3", "Serilog": "2.1.0"

    }, ... } © The Tiny Tech Company 2016 | github/merbla | @matthewerbs | #ndcsydney 18
  19. Tooling Isolation https://hub.docker.com/v2/repositories/microsoft/dotnet/tags/ - latest - core - core-deps -

    1.0.0-core - 1.0.0-core-deps - onbuild - 1.0.0-preview2-sdk - 1.0.0-preview2-onbuild - 1.0.0-preview1 - 1.0.0-preview1-onbuild © The Tiny Tech Company 2016 | github/merbla | @matthewerbs | #ndcsydney 19
  20. © The Tiny Tech Company 2016 | github/merbla | @matthewerbs

    | #ndcsydney 20
  21. The Build © The Tiny Tech Company 2016 | github/merbla

    | @matthewerbs | #ndcsydney 21
  22. Integration (Sinks) • Seq • Azure (Table Storage, AppInsights, DocumentDB)

    • AWS (CloudWatch, Kinesis, DynamoDB) • Elastic • Splunk • & many more... © The Tiny Tech Company 2016 | github/merbla | @matthewerbs | #ndcsydney 22
  23. a Serilog Dockerfile FROM microsoft/dotnet:1.0.0-preview2-sdk ENV SERILOG_BRANCH dev ENV SERILOG_REPO

    https://github.com/serilog/serilog.git # Get Git and Friends RUN apt-get update \ && apt-get install -y wget curl git \ && apt-get -y autoremove \ && apt-get -y clean \ && rm -rf /var/lib/apt/lists/* COPY entry_point.sh entry_point.sh RUN chmod +x /entry_point.sh ENTRYPOINT ["/entry_point.sh"] © The Tiny Tech Company 2016 | github/merbla | @matthewerbs | #ndcsydney 23
  24. An Entry Point # example entry_point.sh git clone -b $SERILOG_BRANCH

    --depth 1 --single-branch $SERILOG_REPO cd serilog/ sh build.sh # example build.sh dotnet restore for path in src/*/project.json; do dirname="$(dirname "${path}")" dotnet build ${dirname} -f netstandard1.0 -c Release dotnet build ${dirname} -f netstandard1.3 -c Release done for path in test/Serilog.Tests/project.json; do dirname="$(dirname "${path}")" dotnet test ${dirname} -f netcoreapp1.0 -c Release done © The Tiny Tech Company 2016 | github/merbla | @matthewerbs | #ndcsydney 24
  25. "Now everyone play nice together!" version: '2' services: consoleapp: build:

    ./console-sample image: serilog-console-sample websample: build: ./web-sample image: serilog-web-sample ports: - 5000:5000 fswebsample: build: ./fsharp-kestrel-sample image: serilog-fsharp-kestrel-sample ports: - 5001:5001 splunk: build: ./splunk image: serilog-splunk ports: - 8000:8000 - 8088:8088 © The Tiny Tech Company 2016 | github/merbla | @matthewerbs | #ndcsydney 25
  26. Show me please.... © The Tiny Tech Company 2016 |

    github/merbla | @matthewerbs | #ndcsydney 26
  27. How might this help you? • Migration of a library

    to .Net Core • Migration of a existing app to .Net Core • Running Windows and you have components that only run on *nix • Getting a closer representation of Production on your workstation © The Tiny Tech Company 2016 | github/merbla | @matthewerbs | #ndcsydney 27
  28. Some notes.. • serilog.net • github.com/serilog/ • github.com/serilog/serilog-extensions-logging • github.com/serilog/serilog-settings-configuration

    • github.com/serilog/serilog-docker © The Tiny Tech Company 2016 | github/merbla | @matthewerbs | #ndcsydney 28
  29. It's YOUR data LOG IT! Thank you! © The Tiny

    Tech Company 2016 | github/merbla | @matthewerbs | #ndcsydney 29