ALTERNATE UNIVERSE DEV

CodingBlocks

Episode 32 – The Twelve-Factor App: Codebase, Dependencies, and Config

Dipping our toes into the DevOps waters with the Twelve-Factor App. How important is depedency management, and how fired would you be if you accidentally leaked your company's source code? News We have a new logo! Allen was right... Soundcloud Thanks for the reviews! GunBlade77 What is the Twelve-Factor App? A methodology for writing applications where the end goal is software as a service - a methodology that grew out of lessons learned among people who have built hundreds of applications and have had to scale them over time. Nothing about Kanban boards, meditation techniques, or ticketing systems - instead, source control, configuration management and services. Similar to Joel Spoelsky's 12 step program, but targetted towards modern web app operations Guiding principles: Keep things declarative - describes WHAT something is supposed to do, as opposed to how to do it - rather it lists the desired results...Does not explicitly list commands or steps" Have a clean contract with the underlying operating system, offering maximum portability between execution environments; Are suitable for deployment on modern cloud platforms, obviating the need for servers and systems administration; Minimize divergence between development and production, enabling continuous deployment for maximum agility; Can scale up without significant changes to tooling, architecture, or development practices. Digital Ocean: CODINGBLOCKS Factor 1: Codebase Each "codebase" must be tracked in a repo There is always a 1-1 correlation between a codebase and an app If there are multiple codebases, it’s not an app – it’s a distributed system. Each component in a distributed system is an app, and each can individually comply with twelve-factor. Multiple apps sharing the same code is a violation of twelve-factor. The solution here is to factor shared code into libraries which can be included through the dependency manager. There will be many deploys of the app - development, staging, production - always same codebase even though different commits may be present Importance: Non-negotiable Factor 2: Dependencies Explicitly declare and isolate dependencies Never relies on existence of system wide packages!!! Can you say goodbye to the GAC?! ... and hello to ASP.NET 5.... Uses a dependency isolation tool to make sure no additional dependencies leak in All dependencies declared explicitly in a manifest - nuget packages file, etc. dependency declaration and isolation must both be used - how in .NET??? (MSBUILD?) makes onboarding new developers easy because they can check out the codebase and run the build and everything should be bundled for them Importance Rating: High Factor 3: Configs An app's configs are things that will vary by environment. Server names, passwords, etc might be different for dev and production Don't prefix your variables w/ environments...gets to be a pain as more environments are created Twelve-Factor recommends environment variables, but they especially forbid storing them in source code! A good test: Can your code be open sourced right now? So, why environemnt variables? Easy to change without updating code, and "orthogonality" .it's easy for me to spin up processes w/ same code but different environments Twelve-Factor app prescribes using environment variables...as opposed to config files, or databases And how do I manage my environment variables?? Resources we like 12factor.net Architecting Apps Twelve-Factor Apps in Plain English Tips & Tricks https://www.codeschool.com/ http://blog.codinghorror.com/programming-your-hands/ http://packery.metafizzy.co/

Episode source