Posts

Docker multi-stage build in Action

Hi everyone,

today I want to show how to create the small docker image for deploying the application.

I've an application which consists of a backend(go application) and angular based front-end application. So let's create the Dockerfile and step by step fill it with commands.
I started with frontend


Next I added the golang builder


For avoiding, the certificate signed by unknown authority error during HTTP request I add trusted certificates

(details more here Stackoverflow issue)


Finally, copy all items to the end image


I keep my container on the quay.io so everyone can see logs and pull the container docker pull quay.io/vdzundza/shoper

All Dockerfile listing here Github Gist

Thanks everyone !

Nginx rewrite rules for hosting angular(any) static app on subroute

Hi everyone,

I decided to reorganise my personal blog and use it mostly as "Notes"

Today, I want to host two websites served by golang application. The simplest solution is to create system service which points to go executable app on the particular port. In a nutshell, there are two separate services which use 9990 and 9991 ports.

Next step I added this simple rule to the Nginx



location /admin {
rewrite /admin/(.*) /$1 break;
proxy_pass http://localhost:9991;
proxy_redirect off;
proxy_set_header Host $host;
}

location / {
proxy_pass http://localhost:9990;
}



So this simple configuration just rewrites URL properly to the admin service and I do not need to add extra `admin` route prefix.

The latest step is set-up base href for the static `index.html` file. We can easily do it with build option `ng build --base-href /admin/`

Thank everyone for reading.

Create table with dynamic rows and configurable row buttons with AngularJS

Hi all,
Today I want to write a short article how to create a table with dynamic configuration for rows. For example, I need to render simple table by data provided from a server and append to each row some extendable buttons, checkboxes etc. for making action on a row. For example, I will use this data:


  app.controller('MainCtrl', ['$scope', function($scope) { var vm = this; var tableData = [{ firstName: 'Viktor', lastName: 'Dzundza', age: 25 }, { firstName: 'Jony', lastName: 'Boyko', age: 24 }, { firstName: 'John', lastName: 'Doe', age: 45 }, { firstName: 'Alisa', lastName: 'Doe', age: 2 } ]; var tableMeta = { columns: [{ name: 'firstName', title: 'First Name' }, { name: 'lastName', title: 'Last Name' }, { name: 'age', …

Using jquery templates for adding form element dynamically in ASP.NET MVC

Image
Hello friends. Today I wanna tell about some obstucles with validation which I've found when I had working with form.
At first I've created two models for binding

using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using DataAnnotationsExtensions; namespace DynamicForm.Models { public class FormViewModel { public int? Id { get; set; } [Required] [StringLength(25, ErrorMessage = "Max firstname length is 25 symbols.")] [DisplayName("First name")] public string FirstName { get; set; } [Required] [StringLength(25, ErrorMessage = "Max lastname length is 25 symbols.")] [DisplayName("Last name")] public string LastName { get; set; } [Required] [Email(ErrorMessage = "Provide correct email address, please.")] [DisplayName("Email")] public string Email { get;…

Some notes about transportation problem

Hello guys. After work I remembered my studying at university. My first thoughts is about solving Monge–Kantorovich transportation problem using a modification of simplex method known as Method of Potentials. Transportation theory investigates methods for optimal allocation resources among consumers and transportation them with minimum cost. For example, suppose we have some factories which provide materials and shops which consume it.

(To be continued)

Improving ...

Short account of what I did:
- I signed up for Machine Learning Stanford course (Link);
- I registered on AI&BigData conference in Odessa Link;
- I am trying to study Clojure.

After studying Clojure I'll describe all troubles which I got during studying and I'll write about my impression of the conference too.

PHP Design Patterns - Strategy

Today I want to explain how to use strategy design pattern in PHP. I tried to use this pattern when I want decouple algorithms for calculating something at runtime. For example, we can dynamically changing methods which will be calculate price of some items using some logic.

Create car, for example:
namespace strategy; abstract class Item{ abstract function getPrice(); } class Car extends Item{ protected $price; public $name; protected $isTuned; public function __construct($name, $price, $isTuned){ $this->name = $name; $this->price = $price; $this->isTuned = $isTuned; } /** * @return bool */ public function isTuned(){ return $this->isTuned; } public function getPrice(){ return $this->price; } }
Suppose we want to separate method which will calculate price with different strategies. Create interface
which will be implemented in each strategy.
namespace strategy; interface …