Posts

Showing posts from 2016

Setup secure Docker Registry with Nginx and SSL

Prerequisites Docker v1.12 installed. (though you could try it with lower version) Docker Compose v1.6 installed. apache2-utils are installed. Ubuntu (but it very similar for other distro). A domain name to run the docker registry. (a subdomain would work too). SSL certificate for the domain to run the docker registry on. Step 1: create docker-compose.yml Create a directory registry and under it create a docker-compose.yml . This docker-compose file create a registry container using the registry:2 image and also a front-end proxy using the nginx:1.10.1 image. The registry container is configured to expose it's port 5000 to other container that links to it (in this case, the proxy container can access the registry via that port) The proxy container is configured to listen to port 80 and 443 on the host. Other nginx configuration are stores under the conf.d directory that are mapped as volume. REGISTRY_HTTP_SECRET Set a secret text for the

How to use ActiveRecord has_and_belongs_to_many (HABTM) association in Rails

When building an application in Rails, often when we need to create relationship between objects, we'll try look for the correct association that we can use based on our own use case. One of the association is  has_and_belongs_to_many , a.k.a HABTM (yep, that acronym exists!). While many articles talks about why one should never use HABTM in place of the has_many..., but I think there's a place for HABTM, in my case, I intend to keep my application small and simple. Let's assume I have a 2 models, " Programmer " and " Project ", a programmer can work on many projects, and a project can have many programmers (obviously right?). To do this in Rails, I took the following steps. Generate the migration file rails g migration CreateJoinTableProgrammerProject programmer project This would generate a migration file like the following: class CreateJoinTableProgrammerProject < ActiveRecord :: Migration def change create_join_table : pro