티스토리 뷰

http://www.habitus.io/ 한글 부분 번역본입니다.

Here's what it takes to build a Docker image: a Dockerfile!

Dockerfiles 간단하죠...

Dockerfile 은 간단하고 알수있는 형식입니다. 바탕이되는 이미지를 선택하고, 파일 추가하고, 명령 실행하고 you're good to go. 아래는 예제:
FROM ubuntu  
RUN apt-get -y install python  
ADD ./a-file /app/a-file  

너무 간단한건가요?

Often times building a real world application takes much more than following simple ADD and RUN steps in a step-by-step fashion. You might want to:

  • Pull code from a private git repository and therefore need your private SSH key in the image during build
  • Add compile-time libraries to your image but don't need them in run-time

또한, how about those "post-build" steps like uploading your compiled executables to S3 or resetting your exception handling system after a successful build and release?


Habitus를 소개합니다

Habits 는 이런 이슈들에 대한 저희들의 응답입니다. 저희를 위해 만들었고 모든사람들이 행복했으면 하는 목적으로 오픈소스로 풀어 제공하고 있습니다.

Habitus 뭔가요?

Habits 는 도커를 위한 빌드 흐름 도구입니다. 다중 Dockerfile들을 복잡한 빌드와 배포 흐름과 결합하도록 해줍니다.

Dockerfile들을 단일 yaml 파일인 build.yml 에 병합은 많은 힘과 유연성을 제공합니다. 다음은 build.yml 예제입니다:
build:  
  version: 2016-02-13 // version of the build schema. 
  steps:
    - builder:
      name: builder
      dockerfile: Dockerfile.builder
      artifacts:
        - /go/src/github.com/cloud66/iron-mountain/iron-mountain
        - /go/src/github.com/cloud66/iron-mountain/config.json
        - /go/src/github.com/cloud66/iron-mountain/localhost.crt
        - /go/src/github.com/cloud66/iron-mountain/localhost.key
      cleanup:
        commands:
          - rm -rf /root/.ssh/
    - deployment:
      name: ironmountain
      dockerfile: Dockerfile.deployment
      depends_on:
        - builder
    - uploader:
      name: uploader
      dockerfile: Dockerfile.uploader
      depends_on:
        - ironmountain
      command: s3cmd --access_key=_env(ACCESS_KEY) --secret_key=_env(SECRET_KEY) put /app/iron-mountain s3://uploads.aws.com
Habitus로 실행 가능합니다
$ habitus -f build.yml -e ACCESS_KEY=$ACCESS_KEY -e SECRET_KEY=$SECRET_KEY
발생하는일들:
  1. Habitus runs each step with the Dockerfile specified in that step.
  2. If any artefacts are specified, they'll be copied from the built image onto the work directory, so they'll be available to the next steps.
  3. Any cleanup commands will run after build. This will result in 'squashing' the image, therefore removing any traces of the unwanted layers. This is particularly useful to get rid of compile time packages or private SSH keys.
  4. If a command is specified, it will run in the build container. This can be a step to upload build artefacts to a we server.

할 수 있는 다른것은?

Habitus can do more than just running build steps. It can:

  • Automatically detect that a step uses another step as the base image FROM and amend the image tags
  • Build complex build dependency tree and run independent steps in parallel
  • Pass environment variables into the build

Multiple instances of Habitus can run in parallel on the same build using unique session IDs. This is useful if you would like to use Habitus for your automated build server.


더 자세한 내용은 어디에?

You can read more about Habitus on its website.


무료입니까?

예! Habitus는 무료고 오픈소스입니다.

Habitus 후원자는?

Habitus is an open source project sponsored by Cloud 66. Fork, modify and conquer, then let us know what you think! 


댓글