<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Javi</title>
    <description>The latest articles on DEV Community by Javi (@javitolin).</description>
    <link>https://dev.to/javitolin</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F556477%2Fd9fb95fc-3868-45e9-9a41-0e31a3b00a61.png</url>
      <title>DEV Community: Javi</title>
      <link>https://dev.to/javitolin</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/javitolin"/>
    <language>en</language>
    <item>
      <title>Azure DevOps CODEOWNERS</title>
      <dc:creator>Javi</dc:creator>
      <pubDate>Sun, 13 Aug 2023 18:19:44 +0000</pubDate>
      <link>https://dev.to/javitolin/azure-devops-codeowners-18gh</link>
      <guid>https://dev.to/javitolin/azure-devops-codeowners-18gh</guid>
      <description>&lt;p&gt;So the other day I came across GitHub's &lt;a href="https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners"&gt;CODEOWNERS feature&lt;/a&gt; and I really liked it. I searched for the same in Azure DevOps but couldn't find something remotely close to it. Then my entrepreneur spirit waked up and I decided to make it myself :)&lt;/p&gt;

&lt;p&gt;But first, what is "CODEOWNERS"?&lt;/p&gt;

&lt;h2&gt;
  
  
  CodeOwners Feature
&lt;/h2&gt;

&lt;p&gt;Some facts:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;When working on a multiservice monorepo, it's very common to have different programmers working on the same repo on different features.&lt;/li&gt;
&lt;li&gt;The programmer who wrote the feature is probably the one that knows best about it.
&lt;/li&gt;
&lt;li&gt;Some other programmer will probably "touch" that code sometime in the future (bugfix for example).&lt;/li&gt;
&lt;li&gt;You want the Pull Request to be as professional and as short as possible.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Thus, CodeOwners came to live.&lt;/p&gt;

&lt;p&gt;CODEOWNERS is a simple idea, each feature/service in the monorepo has an owner. A developer who "owns" that feature, knows it the best and can be held responsible, in a positive way, of that feature.&lt;br&gt;
The CODEOWNERS feature in GitHub is just an easy way of enforcing that the owner will become a reviewer, automatically.&lt;/p&gt;

&lt;h2&gt;
  
  
  In GitHub
&lt;/h2&gt;

&lt;p&gt;To make use of this feature you just need to create a file named "CODEOWNERS" in the root of the repository and add, as they show in the &lt;a href="https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners#codeowners-syntax"&gt;example&lt;/a&gt;, the owners of the services.&lt;br&gt;
From now on every pull request that is opened will be automatically assigned to the owners.&lt;br&gt;
As the CODEOWNERS file is also gitted, changes to it will also be PR'd.&lt;/p&gt;

&lt;h2&gt;
  
  
  In Azure DevOps
&lt;/h2&gt;

&lt;p&gt;There's branch protection in Azure DevOps but it's not as powerful as CodeOwners.&lt;br&gt;
I've created a simple Docker Container that adds this feature to your Azure DevOps project and works the same way.&lt;br&gt;
It can also notify the owner via RocketChat :)&lt;/p&gt;

&lt;p&gt;You can see the code &lt;a href="https://github.com/javitolin/CodeOwners"&gt;here&lt;/a&gt; and download the image from the &lt;a href="https://hub.docker.com/r/javitolin/codeowners"&gt;Docker Hub&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hope you like it! &lt;br&gt;
I'm open for more ideas to add and make Azure DevOps better!&lt;/p&gt;

</description>
      <category>azure</category>
      <category>devops</category>
      <category>productivity</category>
      <category>ado</category>
    </item>
    <item>
      <title>A whole post about logging? Hell Yeah</title>
      <dc:creator>Javi</dc:creator>
      <pubDate>Fri, 27 Aug 2021 09:24:03 +0000</pubDate>
      <link>https://dev.to/javitolin/a-whole-post-about-logging-hell-yeah-5fem</link>
      <guid>https://dev.to/javitolin/a-whole-post-about-logging-hell-yeah-5fem</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;When I started programming, logging was obviously not in my top 10 priorities. It wasn’t even on the list. In fact, I didn’t know what logging was. All I knew was to &lt;code&gt;cout&lt;/code&gt; or &lt;code&gt;Console.WriteLine&lt;/code&gt;, and it was enough.&lt;/p&gt;

&lt;p&gt;Then I began to work. I understood very rapidly that logs are important. What you write, when you write it and how easy it is to understand from them is crucial for the success of a software. &lt;/p&gt;

&lt;p&gt;One of the first tasks I had was to take care of a &lt;a href="https://www.asadodevculture.com/gp/legacy-code-is-scary-and-you-are-doing-it-right-now/" rel="noopener noreferrer"&gt;legacy system&lt;/a&gt;. This system wrote logs to the Windows Event Viewer. Never heard of that, but I quickly managed to get familiar with it. Windows Event Viewer (eventvwr.msc) is a nice GUI that comes with any Windows distribution that lets you see all your system’s logs. It is very easy to write to it and to read the logs from it.&lt;/p&gt;

&lt;p&gt;The logs were (and, sadly, still are) awful. Warning level used to debug (I assume the reason was because the yellow color is easier to recognize and filter). Names of the developers in the logs. No real information on steps, file names, data and such. Exception stack traces from the developer’s computer (with the developer’s path), and more. You get the deal. &lt;/p&gt;

&lt;p&gt;But the worst wasn’t any of that, the worst was the typos. &lt;/p&gt;

&lt;p&gt;It came to a point where I started a table with the typos in the logs. You may think I’m a snob, but there were typos everywhere. So what? Big deal! No, it is bad, it made my work a lot more difficult. In order to debug an error, I would go to the source code and lookup for the error. But because of the typos, I never found the text on the first search. I had to make the same typos to find it. For example, small typos were of the type “exeption” instead of “exception”, but there were bigger ones when you really had to read it twice or more to understand the word hiding there.&lt;/p&gt;

&lt;p&gt;Lately, I started thinking about things that surround the code. Meaning, not the code and logic of the system, but how it will run, what monitors it, how we’ll deploy it and more. For example, we’ve always written systems that run on Windows Services, now we are writing Containers (more about that &lt;a href="https://www.asadodevculture.com/gp/not-using-docker-on-windows/" rel="noopener noreferrer"&gt;here&lt;/a&gt; and &lt;a href="https://www.asadodevculture.com/gp/docker-essentials/" rel="noopener noreferrer"&gt;here&lt;/a&gt;). Soon enough I got to think about the system’s logs. Remembering my difficult times I swore to never make something like that and to bequeath that kind of thinking to my peers. I want to take logging to the place they deserve. I want to be proud of my system’s logs.&lt;/p&gt;

&lt;p&gt;Let’s start with a simple question.&lt;/p&gt;

&lt;h1&gt;
  
  
  Why do you need logs anyway?
&lt;/h1&gt;

&lt;p&gt;Logs are good for investigating. If you write a piece of software for homework, then you don’t need to investigate it. Bugs or such are not important nor interesting once the homework was handed in. You can still have logs and it is always a good idea, but they aren’t required.&lt;/p&gt;

&lt;p&gt;Logs start to become important, ney, necessary, once the software you write is for more than homework. This situation enforces you to have the ability to correctly investigate what is happening in your system. If an error occurred, you must have the possibility to understand why it happened, be able to restore it and, eventually, fix it.&lt;/p&gt;

&lt;p&gt;Logs describe what is happening behind the scenes. It should be enough for a technician to solve problems only by looking at the logs without looking at the code. Logs can alert on issues happening in real-time, they can trigger automations and more.&lt;/p&gt;

&lt;p&gt;We now understand that logs are important, we can move on to how to write them.&lt;/p&gt;

&lt;p&gt;Let’s start by the log’s levels. Log’s levels are important to understand and correctly use them. Incorrectly used log levels will lead to two kinds of logs: An empty log or a messy log.&lt;/p&gt;

&lt;p&gt;If you don’t write anything on the lower levels, you’ll need to be on the higher levels all the time just to see something, this will make your log an empty log for everyday usage.&lt;/p&gt;

&lt;p&gt;If you write lots of logs on the lower levels, you’ll have too much information on the log. This will require you to use a lot of memory and disk for processing and storage, leading to the need to delete logs or pay a lot.&lt;/p&gt;

&lt;p&gt;You want to find that sweet spot in the middle. It’s not a thin line, but it can be easily missed.&lt;/p&gt;

&lt;h1&gt;
  
  
  The levels
&lt;/h1&gt;

&lt;p&gt;Different logs’ framework might call their levels different, but these are the common ones:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Trace/Verbose&lt;/strong&gt; – “So much information” – The lowest level. This level should be able to describe almost line by line what is happening behind the scenes. Parameters values, function calls and such. Exceptions show a full stack trace. This is the technician’s level.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.asadodevculture.com%2Fwp-content%2Fuploads%2F2021%2F08%2Fthe-numbers-mason-what-do-they-mean-300x169.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.asadodevculture.com%2Fwp-content%2Fuploads%2F2021%2F08%2Fthe-numbers-mason-what-do-they-mean-300x169.jpg" alt="The numbers, what do they mean?"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Debug&lt;/strong&gt; – “Many informations” – This is sometimes mistakenly seen as the lowest level, although there are frameworks that this is actually the lowest level. This level should contain almost the same information as Verbose level with a bit less information and description on inner parameters and calls. If this is the lowest level on your framework, use it as Trace/Verbose above. In the end, it should help you Debug.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Information&lt;/strong&gt; – “This is what’s happening” – I call this: The Default level. This should contain contour-like information of the process. What is happening, who is interacting with whom and such. This level should be enough to understand what is happening behind the scenes without giving too much information.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Warning&lt;/strong&gt; – “This flow isn’t entirely ok, but I know how to handle this”. These logs should warn that something bad is happening but it is a handled flow. This can be an expectation failure, input validation failed, a directory missing that we’ll be created and such.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Error&lt;/strong&gt; – “This flow isn’t ok. I still can handle this, but it will be defaulted and you may not continue with your desired flow”. The best way to think about these logs is in catch blocks, but not only. An error has occurred, the system will not function as it should, but it will continue working. Maybe the current request will fail but upcoming requests might work correctly.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.asadodevculture.com%2Fwp-content%2Fuploads%2F2021%2F08%2Fscrewed-we-are-screwed.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.asadodevculture.com%2Fwp-content%2Fuploads%2F2021%2F08%2Fscrewed-we-are-screwed.gif" alt="We are screwed"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Fatal&lt;/strong&gt; – “We are doomed”. This means the system will most probably crush. An unhandled exception happened. We don’t know how to recover from this. Manual interference is mostly required.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Frameworks
&lt;/h1&gt;

&lt;p&gt;In the past (up until a few months ago) I thought that libraries that let you distribute your logs to different destinations are the best and a must-have. &lt;/p&gt;

&lt;p&gt;For example, the &lt;a href="https://logging.apache.org/log4net/" rel="noopener noreferrer"&gt;log4net library&lt;/a&gt; (log4j for dotnet) lets you write in an xml configuration file, where do you want your logs destined to. It can be a rolling file (a file that gets rolled by date or size), it can be to the console (stdout, stderr) and more.&lt;/p&gt;

&lt;p&gt;Log4Net is the first framework I used and it has a special place in my heart. A few years ago, I had to add a feature to an existing system. This system was written many years ago and the logging was custom-made. After adding the feature I was asked for, I asked permission to change all the custom-made logging framework to log4net. This small change allowed later to better the loggings by a lot.&lt;/p&gt;

&lt;p&gt;Every language has at least one framework (not to say tens of frameworks) for logging and they all do their thing pretty well.&lt;/p&gt;

&lt;p&gt;In .Net Core, logging has even a default dependency injection implemented that you can use (&lt;a href="https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.logging.ilogger?view=dotnet-plat-ext-5.0" rel="noopener noreferrer"&gt;ILogger&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;Three months ago (-ish) we deployed our first system entirely based on Docker to a staging environment. We’ve been experimenting a lot with Docker but have never deployed such a system. &lt;/p&gt;

&lt;p&gt;I was familiar with the &lt;a href="https://docs.docker.com/engine/reference/commandline/logs/" rel="noopener noreferrer"&gt;&lt;code&gt;docker logs&lt;/code&gt;&lt;/a&gt; command, that showed the stdout/stderr of the container, but I haven’t stopped to think about what was happening there. One day I saw the &lt;a href="https://12factor.net/logs" rel="noopener noreferrer"&gt;12Factor article about logging&lt;/a&gt;, it said to only write logs to stdout/stderr and let your environment collect those logs for you. This is when I connected the dots. If Docker was able to show me those logs, it probably could write them somewhere. And I was right. Docker collects your logs (stdout/stderr) and writes them into inner log files. Suddenly, all the power of the frameworks to let you decide where you want your logs is dismissed by just writing the logs to the console and letting another system deal with them. Moreover, having to set up the logging destination of each microservice in their configuration instead of just using docker’s logging, was a real drawback.&lt;/p&gt;

&lt;p&gt;Why is this important? First, this allows you to use the same logging mechanism on any environment (Dev, Test, Staging, Production and more). You just need your environment prepared to handle them. We move the logging responsibility from the developer of the microservice, to the environment handler.&lt;/p&gt;

&lt;p&gt;Secondly, no more configuration files telling the logger where to write the logs to. No more empty commits that only change the configuration file. No more deciding on different formats and then changing them.&lt;/p&gt;

&lt;h1&gt;
  
  
  What do we do now?
&lt;/h1&gt;

&lt;p&gt;I’ve set up a BELK environment for the logs.&lt;/p&gt;

&lt;p&gt;I have a &lt;a href="https://www.elastic.co/beats/filebeat" rel="noopener noreferrer"&gt;FileBeat&lt;/a&gt; container listening for Docker’s log files (it even has a &lt;a href="https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-input-container.html" rel="noopener noreferrer"&gt;“Container”&lt;/a&gt; input type!). FileBeat knows how to talk to the docker daemon to receive information on that container (image name, version, host name and such). &lt;/p&gt;

&lt;p&gt;This FileBeat talks to a &lt;a href="https://www.elastic.co/logstash/" rel="noopener noreferrer"&gt;Logstash&lt;/a&gt; container that distributes the logs to the many systems we need to talk to. One of them is a &lt;a href="https://kafka.apache.org/" rel="noopener noreferrer"&gt;Kafka&lt;/a&gt; system from which another Logstash receives the streams and inserts them into an &lt;a href="https://www.elastic.co/elasticsearch/" rel="noopener noreferrer"&gt;ElasticSearch&lt;/a&gt; database and this is all visually from &lt;a href="https://www.elastic.co/kibana/" rel="noopener noreferrer"&gt;Kibana&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Wow. So much buzz words!&lt;/p&gt;

&lt;p&gt;This same method can be cloned almost without any change to any environment or even  system. &lt;/p&gt;

&lt;h1&gt;
  
  
  What do the developers need to do?
&lt;/h1&gt;

&lt;p&gt;Just write their logs. Write away boys! Write logs without caring for anything!&lt;/p&gt;

&lt;p&gt;We write the logs in a JSON format to be able to manipulate them easily in Logstash. But other than that, the developer just has to write whatever he wants, he will be able to see it in the console while developing and nothing has to be changed in order to make it production-ready.&lt;/p&gt;

&lt;p&gt;Writing logs in JSON format? Why not just plain text?&lt;br&gt;
Let’s say you have a method that needs to read from a file using a session Id. &lt;/p&gt;

&lt;p&gt;You could write a log that looks like this:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;“Successfully read file [{fileName}] for session [{sessionId}]”&lt;/code&gt;&lt;br&gt;
This would look good to the naked eye, but it is not very useful for automations, statistics and graphs. Let’s say I wanted to get a list of all the files I read. I would have to make a regex that extracts that info from the text. It is possible, but it will only get harder and harder.&lt;/p&gt;

&lt;p&gt;Instead, you could write a log that looks like this:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;“{ “message”: “Success reading file”, “file”: fileName, “session”: sessionId } “&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This doesn’t look so bad to the naked eye, and it is machine ready for indexing, creating statistics and such.&lt;/p&gt;

&lt;p&gt;I’ve even seen examples where each log type has a unique ID. For our system this is currently an overhead.&lt;/p&gt;

&lt;p&gt;We’ve made a nice infrastructure to ease the writing of the logs (of course, how could we live without an infrastructure). We made a list of the most common values we wrote to the log and made them ‘keys’ for our Json logs. This infrastructure is consumed via a small nuget package containing a lot of helper functions.&lt;/p&gt;

&lt;p&gt;The best part? They still don’t care where the logs go. They just need to see them on the console and everything else will be taken care of. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.asadodevculture.com%2Fwp-content%2Fuploads%2F2021%2F08%2Fill-handle-it-from-here-jacob-black.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.asadodevculture.com%2Fwp-content%2Fuploads%2F2021%2F08%2Fill-handle-it-from-here-jacob-black.gif" alt="I'll handle it from here"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  What have I learned?
&lt;/h1&gt;

&lt;p&gt;Logging is not as easy as it seems, it can be easier than you think and it is crucially important. You need to think about how it will work from the beginning of the system design. It is crucial to it to be as simple as possibly for the developers and for the sysops. It must be flexible for changes and destinations. For example, using Logstash really helped us when another client suddenly appeared and asked to receive some logs from our system too. &lt;/p&gt;

&lt;p&gt;It’s very important to review the logs written; is the level correctly used? For the love of G’d, use a spellchecker, they are free! Have a PR made only for the logs. All of these will help you down the road.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Remember, logs live forever.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>logs</category>
      <category>docker</category>
      <category>architecture</category>
      <category>elasticsearch</category>
    </item>
    <item>
      <title>My Introduction to Docker</title>
      <dc:creator>Javi</dc:creator>
      <pubDate>Fri, 23 Jul 2021 10:00:58 +0000</pubDate>
      <link>https://dev.to/javitolin/my-introduction-to-docker-f8m</link>
      <guid>https://dev.to/javitolin/my-introduction-to-docker-f8m</guid>
      <description>&lt;h1&gt;
  
  
  My Introduction to Docker
&lt;/h1&gt;

&lt;p&gt;My team has decided to transition from Windows Services to Docker Containers. We’ll move to Linux and make all our new systems containerized. Very futuristic!&lt;/p&gt;

&lt;p&gt;I was in charge of checking the Docker world from scratch and figuring out how easy it would be to make the transition.&lt;/p&gt;

&lt;p&gt;To make this POC I decided to make the new system I was in charge of directly on Docker. This would be my POC system. I learned a lot from working this way, and as of today, the system is production ready.&lt;/p&gt;

&lt;p&gt;I can say this whole POC was a success and now I want the whole team to be Docker-ready.&lt;/p&gt;

&lt;p&gt;But what does that mean? I decided to make this list of must-know features to make yourself, what I call, a Docker Developer. These include the ability to build your own image, to debug it – inside and out and more. All written from a developer’s eye.&lt;/p&gt;

&lt;p&gt;This can be seen as a Cheat Sheet on Docker commands, but it is intended to be more than that. Most cheat sheets are just an ensemble of all the common commands with a short description of what they do. I will attempt to make a more complete cheat sheet, explaining what the command does and when and why you will need it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Let’s make sure we are talking the same language
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Docker
&lt;/h3&gt;

&lt;p&gt;“Docker is a set of platform as a Service (PaaS) products that use OS-level virtualization to deliver software in packages called containers” – Wikipedia.&lt;/p&gt;

&lt;p&gt;What does this mean? Docker allows creating a software enclosed package that will run on top of your host device OS (kernel). This is lighter than running a whole VM on top of your OS and it’s more straight-forward than installing the software directly on your OS. Moreover, since it works on top of your OS and not directly on it, the same package can be used on Windows, Linux and MacOS. Say bye-bye to “it works on my machine”!&lt;/p&gt;

&lt;h3&gt;
  
  
  Image
&lt;/h3&gt;

&lt;p&gt;A closed software package. The images are built in a layer formation where the first layer is always the basic “OS” kernel. You can choose if you want the kernel to be Linux based or Windows bases. If you use Windows based, you will be able to run only on Windows.&lt;/p&gt;

&lt;p&gt;Every image consists of a name, a version and a signature. The default version is “latest” and that version image will be used if you don’t specify a specific version.&lt;/p&gt;

&lt;h3&gt;
  
  
  Container
&lt;/h3&gt;

&lt;p&gt;The container is an image in running state. It can actually be running or it can be stopped. Changes you make to the container are not saved the next time the container is started from scratch.&lt;/p&gt;

&lt;h2&gt;
  
  
  The need-to-know commands
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;“docker images” (or “docker image ls”)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The first command I used. This is used to see all the images you have loaded or pulled. Your local registry. If you have just installed docker, you’ll see an empty list.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;“docker pull”&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Used to pull images from a Docker Registry. You most probably won’t use this command directly but when creating an image using a Dockerfile (with the “FROM” command).&lt;/p&gt;

&lt;p&gt;&lt;em&gt;“docker build .”&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Tells docker to use the current directory’s Dockerfile to create a new image. You can add “-t :” to tag the images with a name and a version.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;“docker ps”&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Much like the Linux “ps” command, this command shows the current running containers. This is useful to know the names of the containers that are running and for how long they are running.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;“docker logs ”&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Docker routes all stdout and stderr of the running application to a logging engine. By default it is routed to a log file and can be viewed running this command with the name of the desired container.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;“docker exec -it  /bin/bash”&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This is a really helpful docker command. It allows you to execute a bash into a running container. Let’s say you want to see the inner configuration of the image, the inner filesystem or even the environment variables, then you can attach yourself to the container and “cat” the configuration file, “ls” the filesystem and more.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;“docker save -o .tar”&lt;/em&gt; (and its brother &lt;em&gt;“docker load -i .tar”&lt;/em&gt;)&lt;/p&gt;

&lt;p&gt;Let’s say you have built your image and you want to move it to another location. You most probably will connect to a local/global image artifactory, upload it there and then “pull” the image from the other location. But what if you need to use the image in an offline scenario? You can “docker save” the image as a tar file and then “docker load” the image in the other location.&lt;/p&gt;

&lt;h2&gt;
  
  
  Some architecture decisions made when working on Docker
&lt;/h2&gt;

&lt;p&gt;Making the new system whilst knowing it will work on Docker, made some architecture guidelines.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;No monoliths! Working on Docker really pushes you to work Microservice-ly. When you start to work with Docker and realize how easy it is to start a new image, duplicate it and change it, you realize that there simply isn’t a way a monolithic system is the better choice.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You really focus on the logic. You don’t focus on how and where to write the logs, on where the configuration will be or other stuff that distract you from just writing the logic of this microservice. You know that Docker will take care of that.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You can use whatever language and packages you want! Just make sure the image you’ll build contains them and you are good to go! In Dev/Test/Prod environments you’ll just need to make sure Docker itself is installed and voila!&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;No more thinking of what port I haven’t used yet. As Docker makes a bridge from your host machine to your container, you can use the same port for all of your microservices and just change it in the container.&lt;br&gt;
And more…&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;There is a difference when making an architecture that is based on a containerized environment, and if you are an architect, you must realize this from the beginning and take this into account. It can save you hours of overthinking and over-designing.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>devops</category>
      <category>architecture</category>
    </item>
    <item>
      <title>(Not) Using Docker on Windows</title>
      <dc:creator>Javi</dc:creator>
      <pubDate>Sat, 03 Jul 2021 12:56:34 +0000</pubDate>
      <link>https://dev.to/javitolin/not-using-docker-on-windows-ino</link>
      <guid>https://dev.to/javitolin/not-using-docker-on-windows-ino</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9n2I4UjW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.asadodevculture.com/wp-content/uploads/2021/07/Windows-150x150.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9n2I4UjW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.asadodevculture.com/wp-content/uploads/2021/07/Windows-150x150.png" alt="Windows Logo"&gt;&lt;/a&gt;&lt;br&gt;
I’m a Windows Boy. That’s it, I said it. My first computer was a DOS when I was 4. My father has programmed it to play a game if I write my name and press enter. At age 6 we installed Windows XP and a whole new world appeared in front of me.&lt;/p&gt;

&lt;p&gt;I continued the normal path of Windows Vista (Why), Windows 7 (Thank G’d), Windows 8 (Mmmm), 8.1 (Ok, Ok, back to normal), and now Windows 10 (finally). I work with Windows Servers as well; Windows Server 2008 R2, 2012R2, 2016 and even Windows Server 2019.&lt;/p&gt;

&lt;p&gt;I know Windows pretty well. I wrote C++ programs that interact with Windows Internals. Even wrote a small filter driver. I’ve installed and configured more Windowses than I could count.&lt;/p&gt;

&lt;p&gt;So, following this introduction, you can see why my first thought was to install Docker on Windows.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AGpgE422--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.asadodevculture.com/wp-content/uploads/2021/07/homepage-docker-logo-300x248.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AGpgE422--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.asadodevculture.com/wp-content/uploads/2021/07/homepage-docker-logo-300x248.png" alt="Docker Logo"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I asked another team, which had more practice using Docker, what they thought. They threw me away and told me I was being silly, “Docker should be only on Linux”. I asked why? there’s such a nice GUI for Windows..&lt;br&gt;
Without a good explanation, I thought they were wrong and they just haven’t had any experience working on Docker for Windows. I went on installing Docker on Windows.&lt;/p&gt;

&lt;h2&gt;
  
  
  This is my story
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The installation
&lt;/h3&gt;

&lt;p&gt;First, you’ll need Windows Pro or Windows Server to install Docker. It won’t work on Windows Home. No problem, I thought, and updated my local version to Windows Pro. Then the installation went pretty smooth. The installation finished and a reboot was made. &lt;/p&gt;

&lt;p&gt;Don’t they love reboots in Windows? It feels like there can be a good installation without a nice reboot at the end. Oh, your installation doesn’t require a reboot? That’s a petty…&lt;/p&gt;

&lt;p&gt;After the reboot I opened up Docker and the nice GUI showed up. The Docker icon on the tray showed the “Loading and Unloading” animation for a few seconds. And it continued. And on and on and on. No worries I thought! Maybe another reboot will help? I preferred to ask my old good friend Google. They recommended installing WSL2. I had version 1 and I know 2 &amp;gt; 1 so 2 sounded like the correct way to go. After installing WSL2 (and rebooting) Docker started to work!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dWKrPuMN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://www.asadodevculture.com/wp-content/uploads/2021/07/docker-loading.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dWKrPuMN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://www.asadodevculture.com/wp-content/uploads/2021/07/docker-loading.gif" alt="Docker Loading Logo"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Looking backwards this was the first red flag. Too many things were “hard” at the installation phase. That shouldn’t happen.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  The first run
&lt;/h3&gt;

&lt;p&gt;After Docker started to work, everything else did it’s job correctly. Docker Build, Run, Load, Save and such worked as they should. But that only happened after Docker started running (obviously). Restarting Docker, or restarting Windows was nearly impossible to do straightforwardly. I almost always had to make 2-3 reboots until Docker was ready to work.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This was red flag #2, it’s like the G’d of Windows, Linux and Docker were shouting at me and I decided to ignore it.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  The first bug
&lt;/h3&gt;

&lt;p&gt;We have an app that sends packets over UDP. (Who hasn’t right?) The app worked perfectly outside Docker, but for some reason it didn’t work from inside a Docker container. After a few hours of debugging and logging and breaking and whatnot, we found out that Docker for Windows won’t pass any packet bigger than MTU from inside the container to the host. I mean, why? But fine, we changed the configuration so it would send packets of maximum MTU size and it fixed the issue.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This should have been the last red flag right? But no, we fixed the issue and everything else worked fine, when it worked, so why change anything?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  The Last Straw
&lt;/h3&gt;

&lt;p&gt;I wanted Docker to write all the logs to a file. A simple supported task. I read there was a simple configuration that you can tell Docker to route all stdout and stderr to a log file. You can even configure how many files and of what size they should be, pretty cool! I got stuck trying to understand where the files are. Really. Some said it was under %appdata% but nothing was there. &lt;/p&gt;

&lt;p&gt;And then I found it. The log files are saved inside the Hyper-V image holding the Docker. WHAT. What should I do with that? How can I configure FileBeats (for example) to read that? That was it. I couldn’t find any more excuses to continue using Windows.&lt;/p&gt;

&lt;h3&gt;
  
  
  The salvation
&lt;/h3&gt;

&lt;p&gt;I installed Linux. Ubuntu 20.04 in my case, but that doesn’t really matter. In a matter of 2-3 hours, I’ve changed my two VMs from Windows Server 2016 to Ubuntu 20.04, installed Docker, uploaded my images, configured the network and tested the App. And all that without making a single reboot!!!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rXLOxE1n--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://www.asadodevculture.com/wp-content/uploads/2021/07/docker-good.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rXLOxE1n--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://www.asadodevculture.com/wp-content/uploads/2021/07/docker-good.gif" alt="Docker ftw"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Docker worked as expected from the moment I installed it. The log files appeared and I could see them without making loops in the air. Docker started and restarted as expected whenever I needed. I saw the light.&lt;/p&gt;

&lt;p&gt;You can tell me it is obvious that Docker works better on Linux. Even on Windows it runs on Linux (WSL). But I never heard a real reason why, or a painful experience to really understand why. This is why I wrote this post, to tell my story and warn others.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Please. For your own sake. don’t use Docker on Windows.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you enjoyed reading this, you might enjoy other posts I've wrote! Check them &lt;a href="https://www.asadodevculture.com/"&gt;here&lt;/a&gt;&lt;/p&gt;

</description>
      <category>docker</category>
      <category>windows</category>
      <category>linux</category>
    </item>
    <item>
      <title>How to update yourself</title>
      <dc:creator>Javi</dc:creator>
      <pubDate>Sat, 09 Jan 2021 07:00:58 +0000</pubDate>
      <link>https://dev.to/javitolin/how-to-update-yourself-2i57</link>
      <guid>https://dev.to/javitolin/how-to-update-yourself-2i57</guid>
      <description>&lt;p&gt;&lt;em&gt;Every post I write is based on my own experience and it's brought to you to help you learn from my mistakes&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Do you follow any Design Patterns? Why those? Is it committed and pushed to a repo? Is it easy to understand for next versions? Will anyone (that it isn’t you) be able to pick up from you finished? And more…&lt;/p&gt;

&lt;p&gt;At the beginning, in my job, I was assigned a “mentor” that was able to make me aware of those questions. After about a month and a half I was (apparently) prepared for my first assignment.&lt;/p&gt;

&lt;p&gt;I had the opportunity (later realized how rare this is) to build a new project from scratch. When I say “I” I mean a co-worker and I. Thankfully my co-worker didn’t really care for this new project, so the main parts were mine to create.&lt;/p&gt;

&lt;p&gt;This system was a Server-Client kind of system and was designed under a lot of constraints my company required.&lt;/p&gt;

&lt;p&gt;It was all in C# and we used files to communicate between the modules. After the client would be deployed, there would be no way of contacting it but with our server, no manual intervention could be done. I was a bit afraid the client won’t work as intended (being this my first project…), so one of the modules I worked very hard on was a self-update module. You could send the client a new version of itself and it would self-update – Cool!&lt;/p&gt;

&lt;p&gt;This module made me ask myself the following question:&lt;/p&gt;

&lt;h3&gt;
  
  
  How the software can change its own files while running?
&lt;/h3&gt;

&lt;p&gt;Apparently there are (at least) two ways:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Dynamically write a batch file that will do the update itself. Run it from your application and exit your application. Add a delay in the batch file to allow the application to close before you start changing the files in the batch file. Run the new application from the batch when finished.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Apparently, Windows has this feature/bug (never found out) that allow you to rename files even if they are in use (doesn’t work for Office files, but for Dll’s and Exe’s it does!).&lt;br&gt;
So you could use this to replace your files!&lt;br&gt;
I chose option #2 for my self-update mechanism, it seemed more clean to do it this way rather than creating an awful batch file.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The idea was this:&lt;/p&gt;

&lt;p&gt;If you receive a self-update package, rename all of your files (append “temp” for example) and copy the new files to your folder (thus replacing the old ones). Finish with restarting yourself (Using a small batch file to re-run yourself after you exit). If any of the steps fail, rename the files back.&lt;/p&gt;

&lt;p&gt;This little feature made me really happy!&lt;/p&gt;

&lt;p&gt;I probably tested this feature twice as much I tested all the others.&lt;/p&gt;

&lt;p&gt;Three years have passed from that, and we didn’t need to send a self-update to fix anything. We sent it to upgrade the clients to have more features (and it worked!)&lt;/p&gt;

&lt;p&gt;Not only the client was able to self-update, I felt I have updated myself. This project took me approximately half a year and being the first half year of my work life, it taught me a lot.&lt;/p&gt;

&lt;h4&gt;
  
  
  Here is a list of stuff I think worth mentioning about my experience.
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Always be prepared to changes in the requirements. In my case it was constraints that were added and more features.&lt;br&gt;
This means that all the Design Patterns we learned are really important and can really make the difference.&lt;br&gt;
It sounds like a cliche and we hear it all the time but it is real. Clients don’t know what they want and don’t know what you can offer them. Sit with them and listen to what they really say when they say they need “X”.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Don’t underestimate the power of tests (but don’t overestimate them). “Tests are good as the person who wrote them”. You can easily have a 100% covered project that doesn’t work.&lt;br&gt;
I didn’t write automatic tests for this project and I regret it to this day.&lt;br&gt;
If you don’t have automatic tests that really check your code, you are writing legacy code (more about this in an upcoming post).&lt;br&gt;
You want the next person that looks at your code (let it be yourself) be able to make changes and updates easily, automated tests are a huge part of this.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Projects from scratch are awesome and very rare! If you have the opportunity to write something from scratch grab it with both hands and don’t let it go! It is really rare (unless you work in a start-up I guess).&lt;br&gt;
Why It’s awesome? Because it lets you be creative and you can build it as you want. Moreover, I think you learn the most from creating something from scratch rather than adding feature to an existing code-base.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Being new and an outsider is actually a good thing! I came fresh from the outside. I wasn’t narrow minded and could see things with a fresh look. A lot of things I said where indeed pretty null but a few were good and improved the system and other projects. Don’t be afraid to speak up.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It’s OK to ask questions. Actually, it’s not OK to not ask questions.&lt;br&gt;
You might think you are the best but rest assured you are not. Your co-workers probably have more experience than you have, and even though they don’t know everything about what you are working on, I’m sure they can advise you and will be happy to (no one loves anything more than showing they know something…) &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Write your code like the next person who is gonna look at it is a mad-alcoholic-axe-holding-nothing-to-lose guy. After three years of that system, I sometimes look back at the code and swear the guy who wrote that, then I remember it was me.&lt;br&gt;
Most of the code I write nowadays is one I’m happy to look back at it and it really makes me joy to know I wrote that. (Most, not everything)&lt;br&gt;
I’ll talk more about this in a future post.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You know nothing about development until you have worked on a real project (with clients, managers, co-workers, QA team and more). There is a huge difference between coding for an assignment and coding for your job. This too will have a future post.&lt;br&gt;
This project is up and running up until today and will probably stay online for a few more years.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I would love to hear some of your experiences of your first project on your first job, I think each one feels a bit different and can contribute from its own experience.&lt;/p&gt;

&lt;p&gt;See you on my next post!&lt;/p&gt;

&lt;p&gt;(You can read more like this on my &lt;a href="https://www.asadodevculture.com/"&gt;blog!&lt;/a&gt;)&lt;/p&gt;

</description>
      <category>dotnet</category>
      <category>csharp</category>
    </item>
  </channel>
</rss>
