$30 off During Our Annual Pro Sale. View Details »

Using Docker to help soothe the transition to ....

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

Matthew Erbs

August 04, 2016
Tweet

More Decks by Matthew Erbs

Other Decks in Technology

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. 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
  5. 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
  6. .Net Core a long and winding road.... © Sergey Krivkoc

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

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

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

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

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

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

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

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

    }, ... } © The Tiny Tech Company 2016 | github/merbla | @matthewerbs | #ndcsydney 18
  15. 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
  16. 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
  17. 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
  18. 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
  19. "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
  20. Show me please.... © The Tiny Tech Company 2016 |

    github/merbla | @matthewerbs | #ndcsydney 26
  21. 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
  22. 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
  23. It's YOUR data LOG IT! Thank you! © The Tiny

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