| 1 | ## Overall Docker Setup for Rocq's CI. |
| 2 | |
| 3 | This directory provides Docker images to be used by Rocq's CI. The |
| 4 | images do support Docker autobuild on `hub.docker.com` and Gitlab's |
| 5 | private registry. |
| 6 | |
| 7 | The Gitlab CI will build a Docker image unless the CI environment variable |
| 8 | `SKIP_DOCKER` is set to `true`. This image will be |
| 9 | stored in the [Gitlab container registry](https://gitlab.com/coq/coq/container_registry) |
| 10 | under the name given by the `CACHEKEY` variable from |
| 11 | the [Gitlab CI configuration file](../../../.gitlab-ci.yml). |
| 12 | |
| 13 | `SKIP_DOCKER` is set to "true" in `https://gitlab.com/coq/coq` to avoid running |
| 14 | a lengthy redundant job. For efficiency, users should enable that setting |
| 15 | in forked repositories after the initial Docker build in the fork succeeds. |
| 16 | |
| 17 | The steps to generate a new Docker image are: |
| 18 | - Update the `CACHEKEY` variable in .gitlab-ci.yml with the date and md5. |
| 19 | - Submit the change in a PR. coqbot will detect that the Dockerfile |
| 20 | has changed and will trigger a pipeline build with `SKIP_DOCKER` set |
| 21 | to `false`. This will run a `docker-boot` process, and once |
| 22 | completed, a new Docker image will be available in the container |
| 23 | registry, with the name set in `CACHEKEY`. |
| 24 | - Any pipeline with the same `CACHEKEY` will now automatically reuse that |
| 25 | image without rebuilding it from scratch. |
| 26 | |
| 27 | ## Manual Building |
| 28 | |
| 29 | You can also manually build and push any image: |
| 30 | |
| 31 | - Build the image `docker build -t base:$VERSION .` |
| 32 | |
| 33 | To upload/push to your hub: |
| 34 | |
| 35 | - Create a https://hub.docker.com account. |
| 36 | - Login into your space `docker login --username=$USER` |
| 37 | - Push the image: |
| 38 | + `docker tag base:$VERSION $USER/base:$VERSION` |
| 39 | + `docker push $USER/base:$VERSION` |
| 40 | |
| 41 | ## Debugging / Misc |
| 42 | |
| 43 | To open a shell inside an image do `docker run -ti --entrypoint /bin/bash <imageID>` |
| 44 | |
| 45 | Each `RUN` command creates an "layer", thus a Docker build is |
| 46 | incremental and it always help to put things updated more often at the |
| 47 | end. |
| 48 | |
| 49 | ## Possible Improvements: |
| 50 | |
| 51 | - Use ARG for customizing versions, centralize variable setup; |