Closed kktse closed 2 years ago
Hello Kevin. First, thank you for your interest in Fastest-lap. About your request, sorry I am no expert in this matter. Can you please give me more details about what a docker file does and why it is needed? Thank you!
The motivation for this change is to provide a standardized build environment for fastest-lap
for Linux users. This change reduces the build requirements for Linux users to simply having Docker installed.
Given the minimal documentation regarding the build environment for this project, a Docker image provides standardization and removes individual variables due to differences between computers (ex. compiling on Ubuntu vs compiling on Arch) from the compilation process.
Note: because this change is Linux specific, I placed my changes in scripts/linux
.
Docker is a type of virtualization technology. The Dockerfile
introduced in this change defines the steps to create a Docker image, a pre-built template for the build environment. This image is built locally on the users machine.
The Docker image for this project is based on the latest Ubuntu image on Docker Hub. This corresponds to Ubuntu 20.04 at the time of writing. I chose Ubuntu since this is what your CI uses for Linux builds. Some environment variables are set to facilitate installing packages and then the requisite packages are installed in the image.
The helper script first builds the Docker image using the instructions from the Dockerfile. The second line runs the image as a Docker container, mounting the source code of the project inside the container and dropping the user into an interactive shell. At this point, the user can follow the compile instructions.
In short, I define a "virtual machine" with all the build tools installed in order to compile the project.
The compilation requirements of this project are non-trivial. It took me 2+ hours to get this project to build unsuccessfully either due to problems linking IPOPT or METIS. This limits the usefulness of the project since it is very difficult to build.
The Docker build environment provides a consistent Linux build platform that is agnostic to the host machine configuration.
Please let me know if there's any more context I can provide!
Hello! Thank you very much for this detailed explanation! in my mind, installation should've been straightforward, as in ubuntu and macOS it is prepared to just hit 'CMake ..' and 'make'. However, I have never tried on arch. So thank you.
Two questions to remain (sorry about being so pesky): 1) What can be done about the fastest_lap.py file? Absolute paths were preferred because the user can put the build directory in a completely different location than the source code directory. If the docker thingy always builds the build in the same folder, we could use a relative path for it, right? Maybe we can pass a flag to cmake saying PYTHON_API_ABSOLUTE_PATH:bool and switch between both absolute (default) and relative (only for docker builds) there? 2) Does it need to be in the ./scripts folders? I already have a ./src/scripts folder, and I prefer those to be there. Can it be there, or for some requisite the folder where docker will look for its files is always ./scripts?
I just have added the PYTHON_API_ABSOLUTE_PATH option to CMakeLists. By default it is ON, the docker file should call cmake with -DPYTHON_API_ABSOLUTE_PATH=Off
On Windows I keep having problems while compiling, both with MinGW and with MSVS compilers. So I support this docker approach! Tempted to try and make a dockerfile for a windows config, but not so confident yet.
On Windows I keep having problems while compiling, both with MinGW and with MSVS compilers. So I support this docker approach! Tempted to try and make a dockerfile for a windows config, but not so confident yet.
Yes, I fully agree with you. I just want to clarify some points with @kktse about some changes I did regarding the python library path handling. Thank you!
Great work, Kevin. Thank you for your time! Cheers.
Glad to help. Really awesome project, looking forward to using it!
Nice dog btw!!!
Provide a Dockerized build environment for Linux compilation. The dockerfile will pull
ubuntu:latest
, install the required build dependencies and drop the user into abash
shell. The compilation instructions can be followed from within the docker container.I had difficulty building and running the library locally on my arch linux machine, either having difficulty compiling or having missing references to other packages. To avoid interference with any local machine configuration, this was the solution I came up with to build the project.
Changes
Tested
I can run the example Python notebooks
Problems / Feedback
The package builds as the docker user and in the directory of the docker container. Some of the
cmake
steps generate files likeexamples/fastest_lap.py
with absolute file paths referenced from the docker container, not the host machine. Files created within the docker container inheritroot
permissions.The docker script will drop the user into a docker container and will not automatically build the project.