Git Product home page Git Product logo

febedb's Introduction

Classic C# 3tier app to orchestrated container

You'll recognize this classic 3tier architecture:

Classic 3tier

Febedb stands for Front End, Back End, DataBase.

This repo is the chronicles of the transitioning of this classic 3tier app app to one running in an orchestrated container, paving the way towards microservices like eShopOnContainers experience.

Why

This repo exists for a few reasons, but mainly because I've found it challenging (so far) in transitioning from classic/old school development to modern containerized and orchestrated micro-services architecture in the Microsoft world.

Reasons:

  1. Outline the process of containerizing an existing 3tier app
  2. The challenges of mixing docker, containers, Microsoft .net and Visual Studio (Kestrel)
  3. Docker for Windows: Linux containers vs Windows containers
  4. Self-signed Certificates for localhost in an orchestrated container world (requirements for gRPC)
  5. SQL Server, volumes, dacpac

Methodology

In order to make this as relevant as possible for everyone, the technologies and patterns used those that have traditionally used for this (Asp.Net MVC, Web services) and Sql Server.

Note: This sample is tailored for Microsoft related development tools and frameworks, like Visual Studio, ASP.Net, SQL Server.

The strategy here is a classic lift and shift. There won't be cooler/better frameworks or patterns used to build modern frontend like Angular, React]https://reactjs.org/) or Vue.js]https://vuejs.org/), backend using Web API or gRPC, nor any NoSql like MongoDb. On the other hand, at the end of the transition, your app will in position/state to make it easy to adopt them.

The chronicles are divided in milestones, or steps. The src folder contains a sub folder for each step. Each step has is documented in its own README.md.

Note: I tried to be as relevant to the developer's reality in having the executable from either Visual Studio or from the command line.

Steps

The story begins with the 3 tier app.

Original

The first step Step #1 will be to change to static ports.

step 1

In Step #2 - Docker we'll try to dockerize our app.

step 2

We'll hit a few road blocks, which will lead to our last step, Step #3 - Docker-Compose

step 3

Our 3tier app can now run in a contained and orchestrated system, runnable from a developer's workstation or docker system.

From there, the sky is the limit, for example Kubernetes, micro-services, modernized frameworks and tools, etc.

Technologies

Starting technologies and software:

  • Visual Studio 2019
  • .Net Core 6 (Updated to 6 on 2022.04.15)
  • Language: C#
  • Frontend: Web App (MVC)
  • Backend: Web service
  • Database: Sql Server
  • Docker
  • Kubernetes

Note: .Net core 6 is probably more "modern" than your situation, simply convert your .net Framework app.

Note: Update: on 2022.04.15, updated all projects and Dockerfiles to .Net 6

Requirements

  • Windows 10
  • Docker for Windows with Kubernetes - Windows Containers
  • WSL2
  • Visual Studio 2019
  • .Net Core 6 (Updated to 6 on 2022.04.15)

Note 1: The requirements above are for reference, at the time of this writing.

Note 2: By the time I was done, VS got updated to 2022 and .net to 6.0. You'll see this in step 3.

Naming convention for ports

It's easier to troubleshoot errors when ports follow a certain pattern. The web ports will be using the 5### range:

  1. First digit: 5 - for convenience (like 5000)
  2. Second digit: step-ish: 0: IIS Express, 1: kestrel, 2: docker, 3: docker-compose, 4: Kubernetes
  3. Third digit: 1 = back end, 2 = front end (follows the loading order, ish)
  4. Fourth digit 0 = http, 3 = https (like in 0 for 80 and 3 for 443 ;))
Step Backend http Bakend https FrontEnd http FrontEnd https Sql
0 5010 5013 5020 5023 5043
1 5110 5113 5120 5123 5143
2 5210 5213 5220 5223 5243
3 5310 5313 5320 5323 5343

Note: This numbering by step is probably just too much, I had an idea at the beginning and by the time I realized I wasn't leveraging it, it was a bit late. You can stick to whatever, obviously.

3 tier applications

For a long time, the 3tier architecture was a well-established software application architecture that organizes applications into 3 logical and physical computing tiers:

  • the presentation tier, or user interface
  • the application tier, where information is processed
  • the data tier, where the data associated with the application is stored

Today, a more modern way of building these is via microcontainers.

This is not

This repo is not a course or lecture on micro containers, containers, serverless, or any cloud native technology offerings.

Key takeaways

If you want to use https from container to container in a multi-container environment on your workstation, the built-in dotnet devcert won't work. I opted for OpenSSL.

If you want to deploy a DACPAC to a Sql Server part of your multi-container environment, it's better to have it in a separate process/container.

Feedback

If you find this tutorial-ish practical let me know. If you find errors or there are instructions that aren't clear, let me know, or fix them and send me a pull request. If you have better ways to do things, share your knowledge.

febedb's People

Contributors

dependabot[bot] avatar patricecalvehoc avatar patware avatar

Watchers

 avatar

febedb's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.