4 Packaging applications from source code into Docker Images
Building Docker images is easy. In chapter 3 you learned that you just need a few instructions in a Dockerfile to package an application to run in a container. There’s one other thing you need to know to package your own applications: you can also run commands inside Dockerfiles.
Commands execute during the build, and any filesystem changes from the command are saved in the image layer. That makes Dockerfiles about the most flexible packaging format there is; you can expand zip files, run Windows installers, and do pretty much anything else. In this chapter you’ll use that flexibility to package applications from source code.
Building software on your laptop is something you do for local development, but when you’re working in a team there’s a more rigorous delivery process. There’s a shared source control system like GitHub where everyone pushes their code changes, and there’s typically a separate server (or online service) that builds the software when changes get pushed.
That process exists to catch problems early. If a developer forgets to add a file when they push code, the build will fail on the build server and the team will be alerted. It keeps the project healthy, but the cost is having to maintain a build server. Most programming languages need a lot of tools to build projects--figure 4.1 shows some examples.