소스 검색

blog: docker containers for archaic project

pull/1/head
Rohan Verma 6 년 전
부모
커밋
0fc5403426
5개의 변경된 파일138개의 추가작업 그리고 16개의 파일을 삭제
  1. +64
    -0
      content/blog/2019-08-04-docker-containers-to-build-archaic-projects.md
  2. +70
    -0
      content/blog/2019-08-04.md
  3. +0
    -12
      content/blog/deep-work-a-summary.md
  4. +2
    -2
      layouts/_default/baseof.html
  5. +2
    -2
      layouts/index.html

+ 64
- 0
content/blog/2019-08-04-docker-containers-to-build-archaic-projects.md 파일 보기

@@ -0,0 +1,64 @@
+++
author = "Rohan Verma"
categories = ["notes"]
date = "2019-08-04T07:30:00+00:00"
draft = false
tags = ["notes", "docker"]
title = "Using Docker containers for building Archaic Projects"
type = ""
url = "blog/2019/08/04/docker-containers-to-build-archaic-projects"

+++

Sometimes old projects and libraries require certain specific system library versions that are hard to reproduce, or cumbersome to replicate on our development environment. Docker can be used to simplify the build process of these projects and it is often a lot faster than starting a VM in your machine and using that to build these projects.

I recently found out about such a project at my workplace. This was a C++ binary that was statically compiled, so there was no issue with distribution but the build process had become very complex over time. It seemed to only compile on dependencies that ship with Ubuntu 16.04 Xenial Xerxes. Currently, the project was using a vagrant box, and provisioning it with dependencies. Each time a new binary had to be complied, the VM had to be started, provisioned (install development tools) using a script, setup SSH, and then copy the source into the virtual machine. After that, the VM would be used to run the bash scripts which would build multiple binaries along with the required libraries. These final binaries were then again copied to the host machine using scp.

The initial idea was to replicate the same thing in a Docker container. But can it be done in a better way?

Yes there is a way. A cool thing about Docker is that we can share the filesystem between the host and the container using mounts. Yes, mounting is also possible using VMs but the sheer speed at which you can perform in-place operations using docker run and mounts as compared to a VM is ludicrous. Plus, you don't need to have a VM always running. What we just need to do is to build a container having all the dependencies and dev tools installed and use the dev tools of the container to operate on the host file system.

Let us dive in,

First we will make a Dockerfile having all the required tools and libraries installed. We can save this file in our projects root directory.

```Dockerfile
FROM ubuntu:xenial
RUN apt-get update
RUN apt-get install -y gcc g++ libssl-dev cmake
RUN mkdir -p /etc/myproject
WORKDIR /etc/myproject
```

Notice above, that we have earmarked `/etc/myproject` as the directory where we will mount our project source tree.

The following sample makefile is used to build our project. Only two steps are involved with this file.

1. `make docker-image`
2. `make build`

```Makefile
build: libs myproject ## build all

docker-image: ## build the docker image using the Dockerfile
docker build -t myproject:latest .

libs: ## build the libs
docker run -it -v "${PWD}":/etc/myproject myproject:latest /bin/bash -c 'cd build && chmod +x build-libs && ./build-libs'

myproject: ## build myproject.bin
docker run -it -v "${PWD}":/etc/myproject myproject:latest /bin/bash -c 'cd build && chmod +x build-main && ./build-main'

help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

.DEFAULT_GOAL := help

.PHONY: help build libs myproject
```

Let us look closely at each step required to finally produce the binary.

First, we will run the command `make docker-image` to create a local image from the docker file we hade written. This image has all the required dependencies.

Now, the next step is to run the `libs` and `myproject` steps in order using `make build`. In this step, we mount our hosts working directory to `/etc/myproject` which we had mentioned above. After that we run a command that will run a script that runs `g++` in our case to build the binary. And voila, it is done.

+ 70
- 0
content/blog/2019-08-04.md 파일 보기

@@ -0,0 +1,70 @@
+++
author = "Rohan Verma"
categories = ["notes"]
date = "2019-06-26T07:30:00+00:00"
draft = true
tags = ["books"]
title = "Deep Work by Cal Newport- A summary"
type = ""
url = "blog/2019/06/26/deep-work-a-summary"

+++

I recently read the book Deep Work by Cal Newport. Here are some important key notes from the book I liked.

- In this new economy, three groups will have a particular advantage: those who can work well and creatively
- those who can work creatively with intelligent machines and those who are stars in their field.
- Two Core Abilities for Thriving in the New Economy
- we’ve been spoiled by the intuitive and drop-dead-simple user experience of many consumer-facing technologies,
- If you don’t produce, you won’t thrive—no matter how skilled or talented you are.
- depth is uncomfortable and distraction ubiquitous,
- it’s built on an unstable foundation and can be easily dismissed once you decide to cultivate a deep
- We should not, therefore, expect the bottom-line impact of depth-destroying behaviors to be easily detected.
- In Morozov’s critique, we’ve made “the Internet” synonymous with the revolutionary future of
- We tend to place a lot of emphasis on our circumstances, assuming that what happens to us (or
- As Gallagher summarizes: “Who you are, what you think, feel,
- Gallagher teaches us that this is a foolhardy way to go about your day, as it ensures that your mind
- Gallagher concludes in her book. “I’ll choose my targets with
- “The best moments usually occur when a person’s body or mind
- Ironically, jobs are actually easier to enjoy than free time, because like flow activities they have
- Human beings, it seems, are at their best when immersed deeply in something challenging.
- To build your working life around the experience of flow produced by deep work is a proven path to deep
- Your work is craft, and if you hone your ability and apply it with respect and care, then like the skilled
- The meaning uncovered by such efforts is due to the skill and appreciation inherent in craftsmanship—not
- “I’ll live the focused life, because it’s the best kind
- You have a finite amount of willpower that becomes depleted as you use it.
- The key to developing a deep work habit is to move beyond good intentions and add routines and
- Ritualize An often-overlooked
- it’s not just the change of environment or seeking of quiet that enables more depth. The dominant force
- The presence of the other party waiting for your next insight—be it someone physically in the same
- Christensen walked through the basics of disruption: entrenched companies are often unexpectedly dethroned
- What I needed was help figuring out how to execute this strategy.
- execution should be aimed at a small number of “wildly important goals.”
- lead measures turn your attention to improving the behaviors you directly control in the near future
- it was not so much the intensity of my deep work periods that increased, but instead their regularity.
- Idleness is not just a vacation, an indulgence or a vice; it is as indispensable to the brain as vitamin
- The implication of this line of research is that providing your conscious brain time to rest enables
- attention restoration theory (ART), which claims that spending time in nature can improve your ability
- regularly resting your brain improves the quality of your deep work. When you work, work hard. When you’re
- it’s common to treat undistracted concentration as a habit like flossing—something that
- If every moment of potential boredom in your life—say, having to wait five minutes in line or sit alone
- once we see the distraction problem in terms of brain wiring, it becomes clear that an Internet
- instead schedule the occasional break from focus to give in to distraction.
- you must rewire your brain to be comfortable resisting distracting stimuli. This doesn’t mean that
- We found that one of the biggest differences between memory athletes and the rest of us is in a cognitive
- any-benefit mind-set, as it identifies any possible benefit as sufficient justification for using
- they’re tools, no different from a blacksmith’s hammer or an artist’s brush, used by skilled laborers
- The notion that identifying some benefit is sufficient to invest money, time, and attention
- It’s a zero-sum game. And because your time returns substantially more rewards when invested in high-impact
- This fear that you might miss out has obvious parallels to Nicodemus’s fear that the voluminous stuff
- earning people’s attention online is hard, hard work.
- You “like” my status update and I’ll “like” yours. This agreement gives everyone a simulacrum
- They’re just products, developed by private companies, funded lavishly, marketed carefully, and designed
- the logical foundation of his proposal, that you both should and can make deliberate
- when it comes to your relaxation, don’t default to whatever catches your attention at the moment, but
- If you give your mind something meaningful to do throughout all your waking hours, you’ll
- The value of deep work vastly outweighs the value of shallow, but this doesn’t mean that you must quixotically
- lazy. By instead picking and sticking with a shallow-to-deep ratio, you can replace this guilt-driven
- Marshall McLuhan declared that “the medium is the message,”
- Deep work is important, in other words, not because distraction is evil, but because it enabled Bill
- * The studies I cite are looking at the activity of deliberate practice—which substantially (but

+ 0
- 12
content/blog/deep-work-a-summary.md 파일 보기

@@ -1,12 +0,0 @@
+++
author = "Rohan Verma"
categories = ["notes"]
date = "2019-06-26T07:30:00+00:00"
draft = true
tags = ["books"]
title = "Deep Work - A summary"
type = ""
url = "blog/2019/06/26/deep-work-a-summary"

+++
Hekki

+ 2
- 2
layouts/_default/baseof.html 파일 보기

@@ -31,8 +31,8 @@
{{- $baseof.Content | safeJS -}}
</script>
{{ partial "head/modules.html" . }}
{{ if .RSSLink }}
<link href="{{ .RSSLink }}" rel="alternate" type="application/rss+xml" title="{{ .Site.Title }}">
{{ if .OutputFormats.Get "RSS" }}
<link href="{{ .RelPermalink }}" rel="alternate" type="application/rss+xml" title="{{ .Site.Title }}">
{{ end }}
<link rel="canonical" href="{{ .Permalink }}">
{{ if (isset .Params "prev") }}

+ 2
- 2
layouts/index.html 파일 보기

@@ -44,7 +44,7 @@

You can read my <a class="no-underline text-grey-dark" href="/blog">blog</a> where
I try to write about what I am doing and things I find interesting. I have organized my blog using categories
and tags. You can navigate through my blog by using them, or if you prefer to view by date, you can visit
and tags. You can navigate the blog by using them, or if you prefer to view by date, you can visit
<a href="blog_list">the blog listing page</a>.
<br>
<br>
@@ -63,7 +63,7 @@

<br>
My blog is also available through <a href="https://rohanverma.net/blog/index.xml">[RSS]</a>
My blog is also available via <a href="/blog/index.xml">[RSS]</a>

{{ end }}
{{ define "footer" }}

Loading…
취소
저장