Skip to content

Docker Files

Anjia Wang edited this page Oct 20, 2020 · 8 revisions

Build from scratch

There are three important files which need to be updated:

  • Dockerfile.base - This is the base docker file that loads the ubuntu environment.
  • Dockerfile.middle - In this docker file we add the user and user group required for the docker environment. This file is dependent upon freecompilercamp/pwc:base, which is an image built from Dockerfile.base.
  • Dockerfile.dind - This is the main docker file. This is the file where we set up our environment, add required tools, like LLVM and ROSE, etc. This file is dependent upon freecompilercamp/pwc:base, which is an image built from Dockerfile.middle.

To build a docker file we use the following command:

docker build -f <docker_file_name> -t <image_name> .

In our case we will build the three files individually in the order Dockerfile.base, Dockerfile.middle and the Dockerfile.dind

cd ~/freeCompilerCamp/play-with-compilers/dockerfiles/dind
docker build -f Dockerfile.base -t freecompilercamp/pwc:base .
docker build -f Dockerfile.middle -t freecompilercamp/pwc:middle .
docker build -f Dockerfile.dind -t freecompilercamp/pwc:full .

The order of build is important as the files are dependent on other files.

Build the final docker image only

Most of the time, users do not need to build the first two docker images, which will be updated by FreeCC team periodically instead. Users can first pull the latest image first, and then build their own docker images based on freecompilercamp/pwc:middle directly.

Given a dockerfile Dockerfile.rose-debug based on freecompilercamp/pwc:middle:

docker pull freecompilercamp/pwc:middle
cd ~/freeCompilerCamp/play-with-compilers/dockerfiles/dind
docker build -f Dockerfile.rose-debug -t freecompilercamp/pwc:rose-debug .

Push/Update docker images on Docker Hub

The docker images above are built and stored locally. They can be pushed to Docker Hub to let others use it. Please note that the uploading docker image will overwrite the older version if it exists on Docker Hub.

Given the docker image freecompilercamp/pwc:rose-debug we just build, and a Docker Hub account can write to the repository freecompilercamp/pwc:

# login to the Docker Hub account having proper write access
docker login
# Push the docker image
docker push freecompilercamp/pwc:rose-debug

Now the local version of docker image freecompilercamp/pwc:rose-debug has been pushed to Docker Hub. Other users can get this particular docker image using:

docker pull freecompilercamp/pwc:rose-debug