The docker GNAT contains the Dockerfiles necessary to build a x86-64 Linux GNAT Pro docker image for use in CI or general dockerized context.
The repository has the following directories:
gnatpro-deps/
Dockerfile for a base image used to build the GNAT Pro toolsuite.gnatpro/
Dockerfile for building a working compiler container, using a user-provided GNAT Pro release package.
In order to get a GNAT Pro release package, see GNAT Pro versions.
- You must have a recent version of Docker.
- Scripts are developed and tested under a recent Linux distribution. Portability issues may arise for building the images under Windows or MacOS.
For the GNAT Pro image:
- Put linux x86-64 GNAT Pro release in the
gnatpro/
directory - Run the
create_image
script (see below)
You will probably have access rights error, add yourself to the docker group with
sudo usermod -aG docker $USER
then restart your session (this may require a full OS restart).
or else run with sudo
sudo create_image
You can experiment performance issues on macOS. This is due to the way Docker is designed, since Docker engine, on macOS and Windows, needs a Linux Kernel, so it runs Docker into a Virtual Machine.
In order to increase performance, notably for I/O disk, you have to use VirtioFS (Docker Desktop > Settings > General > Choose file sharing implementation for your containers). That way, bind mount performance will be increased. It is also recommended to use named volumes when it is possible.
With $gnat_release
as the GNAT Pro .tar.gz
release filem and $gnat_version
as the GNAT Pro
version number.
Run ./create_image --gnat_version=$gnat_version $release_file
NB: If you're unsure of the version number, let the argument empty for the script to infer it.
This will build two images
docker:deps
for package dependencies and minimal toolingdocker:$gnat_version
for compilation, egdocker:20.2
.
You can then use the docker:$gnat_version
image to spawn new containers for compilation.
Warning: Due to some docker limitations, the release file will be copied to the gnatpro/
dir. It
can safely be removed at the end of build.
Once you have created and tagged an image, you can check that GNAT is working properly by running a compilation of the examples.
docker run --entrypoint make -t gnat:$gnat_version -C /usr/gnat/share/examples/gnat RUN_DINERS=0
It should compile and run all the GNAT examples, and finish on a successful error code.
docker run --entrypoint bash -it docker:$gnat_version
will give you access to a console shell
on the image.
You can then disconnect by either entering Ctrl+D or the exit
command.