Posts

Create a Navigation loading bar for Angular with PrimeNG

Image
Create a Navigation loading bar for Angular with PrimeNGIn Angular, it is common practice to execute commands prior routing a page using guards and resolvers. Guards prevent the routing from occuring until the condition turns to true and resolvers prevent the routing from occuring until the data is returned. Those actions can take time to complete and during the time being, the component will not load leaving the user with an impression of unresponsiveness. Today we will see how we can implement a navigation loading bar for Angular using PrimeNG progress bar component in two parts:Setup an Angular projectPrimeNG Progress barIf you are unfamiliar with the Angular router, you can have a look at my previous blog post explaining the feature of the router https://kimsereyblog.blogspot.com/2017/06/how-to-use-angular-router.html.1. Setup an Angular projectWe start by creating a project and installing PrimeNG.npm install primeng --save npm install primeicons --save Next we also install Bootst…

Monitor Upstream Response Time with Nginx and CloudWatch

Image
Monitor Upstream Response Time with Nginx and CloudWatchLast week we saw how we could Setup CloudWatch to push logs from our application to CloudWatch. Apart from the application logs, another type of logs that is worth looking into are the access logs from Nginx. Nginx being the entrypoint of the application, every traffic in and out goes through it and today we will see how we can leverage its access logs to monitor the response time of our application from CloudWatch in three parts:Setup Nginx to log upstream response timeSetup logs to be pushed to CloudWatchSetup metrics filter on CloudWatch1. Setup Nginx to log upstream response timeBy default Nginx does not log the upstream response time. In order to print it, we can create a new log format which includes it and configure logs to be written into a file using that format. We can add our log configuration in a file called log_format.conf which we can place under /etc/nginx/conf.d/ and nginx will include the configuration under htt…

Serilog with AWS Cloudwatch on Ubuntu

Image
Serilog with AWS Cloudwatch on UbuntuFew weeks ago we saw How to configure Serilog to work with different environment. At the end of the post, we saw briefly how to get the structured logs synced to Cloudwatch. Today we will explore the configuration in more details.Unified Cloudwatch agentLiterate and json logs with SerilogDebug the Cloudwatch agent1. Unified Cloudwatch agentThe Unified Cloudwatch agent can be installed by following the official documentation https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/UseCloudWatchUnifiedAgent.html. There is a previous version of the Cloudwatch agent, this new version, introduced in December 2017, unifies the collection of metrics and logs for Cloudwatch under the same configuration.To install the agent, execute the following commands:mkdir ~/tmp cd tmp wget https://s3.amazonaws.com/amazoncloudwatch-agent/linux/amd64/latest/AmazonCloudWatchAgent.zip unzip AmazonCloudWatchAgent.zip sudo install.sh This will install the agent in the /opt/…

Basic Authentication with Nginx

Basic Authentication with NginxBasic authentication provides an easy way to password protect an endpoint on our server. Today we will see how we can create a password file and use it to enable basic authentication on Nginx.Create a passwordEnable basic authenticationReuse configurationIf you haven’t seen Nginx before, you can have a look at my previous blog post on Getting started with Nginx1. Create a passwordTo create a password, we will use the apache2-utils tool called htpasswd.sudo apt-get update sudo apt-get install apache2-utils htpasswd allows use to create passwords encrypted stored in a filesudo htpasswd -c /etc/myapp/.htpasswd user1 -c is used to create the file. If we want to add other users we can omit the parameter.sudo htpasswd /etc/myapp/.htpasswd user2 Now if we navigate to /etc/myapp/ we will be able to find our .htpasswd file containing encrypted passwords together with usernames.2. Enable basic authenticationEnabling basic authentication can be achieved by using th…

Gitlab CI/CD with pipeline, artifacts and environments

Image
Gitlab CI/CD with pipeline, artifacts and environmentsAlmost a year ago I wrote about how we could setup CI/CD with gitlab pipeline. I showed a very simple 3 stages pipeline build/test/deploy. Since then Gitlab has improved considerably their CI tool with features simplifying releases management. Today we will revisit pipelines and introduce few concepts which will help in managing releases.PipelineReleasesArtifactsEnvironments1. PipelinePipeline are defines as jobs. Each job can be part of a stage in the pipeline and multiple jobs can run concurrently if part of the same stage.The pipeline is define in a .gitlab-ci.yml file placed at the root of the application.We can setup our own runner or use a shared runner from Gitlab. The shared runner runs on Docker therefore it’s possible to build the dotnet image and build our dotnet application.Here is the pipeline we will be using as example pipeline:image : microsoft/dotnet:latest stages: - build - test - package - deploy build:…

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…