Posts

Showing posts from October, 2018

Basic Authentication with Nginx

Basic Authentication with Nginx Basic 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 password Enable basic authentication Reuse configuration If you haven’t seen Nginx before, you can have a look at my previous blog post on Getting started with Nginx 1. Create a password To 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 file sudo 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 authentication Enabling basic authenti

Gitlab CI/CD with pipeline, artifacts and environments

Image
Gitlab CI/CD with pipeline, artifacts and environments Almost 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. Pipeline Releases Artifacts Environments 1. Pipeline Pipeline 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 - pa

Setup a Jenkins Pipeline for local development environment in Docker container

Image
Setup a Jenkins Pipeline for local development environment in Docker container CI/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 docker Jenkins pipeline Sim

Docker compose an ASP NET Core application with SQL Server

Image
Docker compose an ASP NET Core application with SQL Server Last 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 own Setup an ASP NET Core application with SQL Server Setup a Flyway as migration tool 1. Setup SQL Server container on its own If 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 spec