Giter Site home page Giter Site logo

40a / dockerize-me Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fiunchinho/dockerize-me

0.0 2.0 0.0 12 KB

This tool lets you Dockerize your applications using best practices to define your Dockerfile and Docker entry point files.

Shell 14.73% Python 85.27%

dockerize-me's Introduction

Dockerize Me

Docker Hub Docker Pulls Docker Stars

Tired of copy/pasting Dockerfiles around? Not sure about best practices for Dockerfiles or Docker entry points? This tool lets you Dockerize your applications using best practices to define your Dockerfile and Docker entry point files.

You just need to mount your app into the /code folder and follow the instructions. It'll generate a valid Dockerfile, and, if needed, a valid docker-entrypoint.sh file to be used as entry point.

Example

You can run this utility with Docker

$ docker run -it --rm -v $PWD:/code fiunchinho/dockerize-me

Your email: [email protected]
Your full name: Alice Wonderland
Does the container run Java? [False] 
Which file/folder needs to be copied to the container? It'll be copied into '/code' [.] 
Which port do you want to expose? [No ports exposed] 
Do you need an entrypoint to do stuff before running the app? [False] 
Which command needs to be executed to start your application? Your app lives in '/code' python /code/dockerize-me/dockerize.py
System dependencies (f.e python=2.7.11-r3 py-pip=7.1.2-r0): python=2.7.11-r3 py-pip=7.1.2-r0
App dependencies command (f.e pip install -r requirements.txt): [False] pip install -r requirements.txt

You can build your container running the following command: 
docker build \ 
    --build-arg git_repository=`git config --get remote.origin.url` \ 
    --build-arg git_branch=`git rev-parse --abbrev-ref HEAD` \ 
    --build-arg git_commit=`git rev-parse HEAD` \ 
    --build-arg built_on=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \ 
    -t your_image .

This has generated a Dockerfile. If you have selected to use a docker entrypoint, a file called docker-entrypoint.sh will be generated. Before building your image, give execution permissions to this file.

Motivation

This project allow people to easily create nice Dockerfiles to dockerize their applications. Besides, it's a way to document how to craft good Docker images.

Images

This tool uses the following images to keep your Docker images as tiny as possible

Init system

We use tini as init system, so you don't have problems with signals or zombie processes.

Metadata

All our images have special labels that help us determine which is inside the image. This tool also copies the Dockerfile used to build the image inside the container. The labels added to the images are

  • git.repository url of the git repository
  • git.commit sha1 hash of the commit when the image was built
  • git.branch git branch when the image was built
  • build.dockerfile path to the Dockerfile inside the container. Normally /Dockerfile
  • build.on date and time when the image was built

Once you've generated the Dockerfile, you can build your image with

docker build \ 
    --build-arg git_repository=`git config --get remote.origin.url` \ 
    --build-arg git_branch=`git rev-parse --abbrev-ref HEAD` \ 
    --build-arg git_commit=`git rev-parse HEAD` \ 
    --build-arg built_on=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \ 
    -t your_image_name .

Developer Experience

Trying to make life easier for developers, images that need a docker entry point and images that don't, they both accept commands the same way. Images created with this tool let you

  • Run the default command docker run -it --rm -v $PWD:/code fiunchinho/dockerize-me
  • Get an shell docker run -it --rm -v $PWD:/code fiunchinho/dockerize-me sh
  • Use a different command docker run -it --rm -v $PWD:/code fiunchinho/dockerize-me python --version

Credits

I learn many of these concepts thanks to garethr, jpetazzo or jbaruch. You should definitely listen to them.

dockerize-me's People

Contributors

fiunchinho avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.