Posts

Setup a Jenkins Pipeline for local development environment in Docker container

Image
Setup a Jenkins Pipeline for local development environment in Docker containerCI/CD pipelines allow us to automatically build, test and deploy code changes. With Jenkins pipeline, the pipeline itself is generated from a file called the Jenkinsfile which, usually, is source controlled together with the source code repository. When we need to push new changes, what we would usually do, is test locally and then commit to the repository. From there, the Jenkins pipeline will trigger and build, test on the integration server and deploy to a testable environment (DEV/QA). But what do we do when the changes that we are making are on the Jenkinsfile itself? How do we test locally the validity of the Jenkinsfile or more simply, how do we try on a sandbox a Jenkins pipeline to learn how to write a Jenkinsfile? Today we will see how we can setup a sandbox with a full CI/CD deployment which can be quickly brought up and teared down for testing.Jenkins server via dockerJenkins pipelineSimulate dep…

Docker compose an ASP NET Core application with SQL Server

Image
Docker compose an ASP NET Core application with SQL ServerLast week we saw how we could install and run an ASP NET Core application in a container, we saw how Visual Studio uses docker-compose to setup our services. Today we will see how we can use compose to setup a cluster composed by an ASP NET Core application container with a SQL Server container and how we can place in a third party process. This post will be composed by three parts:Setup SQL Server container on its ownSetup an ASP NET Core application with SQL ServerSetup a Flyway as migration tool1. Setup SQL Server container on its ownIf you haven’t installed Docker, follow my previous blog post.The SQL Server Docker image can be downloaded from mcr.microsoft.com/mssql/server:2017-latest. So first we can start by running the container:docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=MyPassword001" -p 1433:1433 --name sqlserver-test -d mcr.microsoft.com/mssql/server:2017-latest -e specifies an environment vari…

Deploy ASP NET Core application on Docker Linux container

Image
Deploy ASP NET Core application on Docker Linux container from WindowsFew weeks ago we saw how we could run ASP NET Core application on Ubuntu. This proving that a .NET Core Application can run on a Linux system, today we will be taking it a step further and see how we can deploy our application in a Docker Linux container. This post will be composed by three parts:Install Docker on WindowsDocker basic commandsCreate ASP NET Core application1. Install Docker on WindowsThe first step is to go to the official site, sign up and download Docker CE.
Once downloaded, install Docker.After being installed you should be able to right click on the icon > Settings on the Docker notification icon and see that Docker is running by checking the status at the bottom left, it should say Docker is running.Open PowerShell and type docker run hello-world.$ docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world d1725b59e92d: Pull compl…

Setup Continuous Integration and Deployment for dotnet library with Appveyor and FAKE

Setup Continuous Integration and Deployment for dotnet library with Appveyor and FAKELast week we saw a flow to manage versioning and releases. As a continuation of last week, today I will show how we can setup versioning and releases for open source projects by configuring Appveyor and using FAKE to setup a build script.Configure AppVeyorFAKE1. Configure AppVeyorConfiguring AppVeyor is done via a yaml file appveyor.yml at the root of the repository. Then from the site https://www.appveyor.com/, we can sign in with our GitHub credentials and add the repository to the AppVeyor projects. All the settings in the settings tab can be configured in the yaml file.appveyor.yml settings can be seen in multiple sections:global environmentbuildtestartifactdeployThe global configuration is where we configure the context of the build,# 1. version: '{build}' image: Visual Studio 2017 skip_branch_with_pr: true skip_commits: files: - docs/**/* - '**/*.md' - .gitignore pu…

Versioning for open source library

Versioning for open source libraryFew weeks ago I explained how Gitversion can be used to apply semantic versioning to projects based on commit and tag history.
Today I will dive deeper in the purpose of versioning and introduce a flow which can be followed to version open source project libraries by looking into four important parts in the lifecycle of an open source library.Version with Semantic versioningBranching strategy and CommitsContinuous Integration and Releases1. Version with Semantic versioningSemantic versioning is ideal for versioning libraries. It is formed by three numbers {major}.{minor}.{patch}. Each number is used to indicate to the user the level of safety for upgrading the library.Upgrade of the major is risky and has chances to contain breaking changes, therefore looking at release notes or looking for migration would be recommended.Upgrade of the minor has lesser risk and can be used to show availability of new features.Upgrade of the patch is not risky and is u…

Implement timeout and retry policies for HttpClient in ASP NET Core with Polly

Implement timeout and retry policies for HttpClient in ASP NET Core with PollyFew weeks ago I explained [how to use the new HttpClientFactory. This freed ourselves from managing the confusing lifecycle of a HttpClient and at the same time allowed us to setup commmon options like base address for all HttpClient injections in our classes. Today we will see how we can setup timeout and retry policies for the HttpClient in in ASP NET Core using Polly.Setup a simple service using HttpClientInstall Polly extensions for ASP NET CoreSetup Polly policies1. Setup a simple service using HttpClientIn the previous blog post we saw how we could setup a HttpClient and register it to the service collection.Here is a simple service client which will be injected throughout the application:public interface IMyApiClient { Task<HttpResponseMessage> Get(); } And here is the implementation:public class MyApiClient : IMyApiClient { private readonly HttpClient _client; public ApiClient(Http…

Continuously deploy infrastructure with GitLab Pipeline

Continuously deploy infrastructure with Gitlab PipelineFew weeks ago we saw how we could Setup continious integration and deployment to deploy an application using Gitlab Pipeline. We configured a service with systemd and had an ASP NET Core application automatically deployed when code was pushed to the repository. This automation allows us to reduce interaction with the server and reducing the manual work. The “infrastructure” configurations like systemd service files and nginx site files must also be created or edited on the server therefore it makes sense to also have them automatically deployed. On top of that, it makes even more sense to have them save in repository and source controlled. Today we will see how we can leverage Gitlab Pipeline to setup a continuous deployment for our infrastructure files in three parts:Setup the repositorySetup the runner jobDeploy the configurations1. Setup the repositoryWe start first by creating a repository with the same structure as our server…