Skip to content

Instantly share code, notes, and snippets.

View zeagord's full-sized avatar
:shipit:
Building stuffs...

Raja Ganesan zeagord

:shipit:
Building stuffs...
View GitHub Profile
@zeagord
zeagord / DockerStorage.md
Last active April 17, 2017 12:45
How to change the default docker image location in a virtual machine

PROBLEM

We ran in to a lot of space issues with storing docker images in Azure cloud VMs. Because by default docker images, layers and containers are stored in the

/var/lib/docker

It is the same with the Amazon AWS as well.

The problem with this is most of the virtual machines have a very limited space in the OS Disk and the space can run out very soon. It is wise to save the docker images and attach your data containers to point a mount volume.

@zeagord
zeagord / UniqueStringTask.java
Last active October 17, 2017 08:42
Find First Unique String in an Array
import java.util.*;
/**
* Created by rg3 on 10/17/17.
*/
public class UniqueStringTask {
private static String findFirstUnique(String ...names){
if (names.length ==0) { // Check for empty array
/**
* Created by rg3 on 10/17/17.
*/
import java.util.ArrayList;
public class NoOfStories {
static int small=1;
static int large=2;
@zeagord
zeagord / CustomRestTemplate.java
Last active May 2, 2018 06:58
HttpClientConnection Factory
@Bean
public ClientHttpRequestFactory createRequestFactory(@Value("${connection.timeout}") String maxConn) {
PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();
connectionManager.setMaxTotal(maxTotalConn);
connectionManager.setDefaultMaxPerRoute(maxPerChannel);
RequestConfig config = RequestConfig.custom().setConnectTimeout(100000).build();
CloseableHttpClient httpClient = HttpClientBuilder.create().setConnectionManager(connectionManager)
.setDefaultRequestConfig(config).build();
return new HttpComponentsClientHttpRequestFactory(httpClient);
@zeagord
zeagord / node-docker.md
Last active September 13, 2019 16:22
How to build small Node JS Docker Image and decrease the build time

When we were trying to create a docker image for our Node JS based application, we chose to use the official Node docker image (~700MB). On top of that we need to add the node modules, business logic, etc and so on. The final image size was staggering (~1.2GB). It was not what we wanted. Secondly, the average build time to do NPM install and run a grunt task totally took 15 minutes for every build. I am not even talking about the pain of configuring this for different CI/CD pipelines and environments.

The initial docker file was looking something like this:

Initial Docker File

FROM node:6.10.1-alpine
docker build -t order-service:latest .
docker run -p 9910:8080 order-service:latest
docker images
docker ps # This will give the container id
docker exec -it <container id> /bin/sh
@zeagord
zeagord / gist:49038615d5335cb5768685eca405d2d0
Last active October 3, 2019 08:09
Steps for Microsevices