Skip to content
This repository has been archived by the owner on Mar 1, 2023. It is now read-only.

tomasz-oponowicz/microcontainer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 

Repository files navigation

Microcontainer

A small script which helps you shrink size of Docker images.

Unfortunately Docker doesn't solve the problem of large images out of the box. Squashing images can help but it forces you to include extra cleanup commands. Sometimes this can be a headache.

The solution is to split responsibilities between Dockerfile.build and Dockerfile.

Dockerfile.build builds application artifacts. This can be anything, from a static website to a standalone application.

Dockerfile is an execution environment. Artifacts, from the previous image, are copied here. Development tools aren't included which allows you to create a ridiculously small image.

The example directory contains a sample use case. This is a React application which requires development tools during build time. Thanks to the script the final image is very lightweight:

Image Size
microcontainer-build (Dockerfile.build) 266.4 MB
microcontainer (Dockerfile) 5.271 MB

Usage

Prerequisites

Instructions

Execute:

$ cd ./example
$ ../build.sh
$ docker run -p 80:80 microcontainer

...it's possible to define a custom name, tag and artifacts path, for example:

$ cd ./example
$ ../build.sh myproject 1.0 /workspace/.
$ docker run -p 80:80 myproject:1.0

...more information in the build.sh file.

What's next

Feel free to test it against your Dockerfile.build and Dockerfile.

About

A small script which helps you shrink size of Docker images.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published