Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dockerfile #51

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft

Add Dockerfile #51

wants to merge 4 commits into from

Conversation

pawel-czyz
Copy link
Member

@pawel-czyz pawel-czyz commented Feb 11, 2025

This is an attempt to provide a Dockerfile, as specified in #47.

I first built the image with

$ sudo docker build -t covvfit .
[+] Building 203.0s (8/8) FINISHED                                                                                                             docker:default
 => [internal] load build definition from Dockerfile                                                                                                     0.0s
 => => transferring dockerfile: 186B                                                                                                                     0.0s
 => WARN: FromPlatformFlagConstDisallowed: FROM --platform flag should not use constant value "linux/amd64" (line 1)                                     0.0s
 => [internal] load metadata for docker.io/library/python:3.11-slim                                                                                      0.4s
 => [internal] load .dockerignore                                                                                                                        0.0s
 => => transferring context: 2B                                                                                                                          0.0s
 => [1/4] FROM docker.io/library/python:3.11-slim@sha256:42420f737ba91d509fc60d5ed65ed0492678a90c561e1fa08786ae8ba8b52eda                                0.0s
 => CACHED [2/4] WORKDIR /app                                                                                                                            0.0s
 => [3/4] RUN pip install --no-cache-dir covvfit==0.2.0                                                                                                200.7s
 => [4/4] RUN which covvfit                                                                                                                              0.1s 
 => exporting to image                                                                                                                                   1.6s 
 => => exporting layers                                                                                                                                  1.6s 
 => => writing image sha256:c817c82088cc024d1fe8d61f0ad07a98a6b5074d01f6e46639980c7fdda3e133                                                             0.0s 
 => => naming to docker.io/library/covvfit    

$ sudo docker image ls       
REPOSITORY   TAG       IMAGE ID       CREATED         SIZE
covvfit      latest    c817c82088cc   6 minutes ago   996MB

Some comments on this:

  • This required about 3-4 minutes and resulted in a large 1 Gb image, as it required downloading quite a lot of packages (e.g., jaxlib is over 100 Mb, SciPy is over 40 Mb, and NumPy is about 20 Mb).
  • It think it may be installing some unnecessary dependencies (at some point it used to install pillow, which is not an explicit dependency).
  • I'm not sure if it'll run on M1 chips properly. Here some ideas of using FROM --platform=linux/amd64 are proposed, which I used.

Then, I ran it with:

$ sudo docker run --rm -v ./data/main:/data -v ./output:/output  covvfit infer /data/deconvolved.csv /data/var_dates.yaml /output/test_run --config /data/config.yaml

As you can see, there are some -v flags: I had to link some directories, as the Docker container by default is isolated and does not see the filesystem.

Obstacles

I think the following should be discussed:

  • Do we want to run covvfit on Docker in this manner? On one hand, this way it should be more reproducible. On the other one, perhaps mounting the directories with -v flag brings more confusion to the user than benefits. Perhaps we should think how to streamline the interface more...
  • Does it run on M1 chips?
  • We should try to reduce the image size.

@pawel-czyz pawel-czyz marked this pull request as ready for review February 11, 2025 22:40
@gordonkoehn
Copy link

gordonkoehn commented Feb 12, 2025

There is an easy solution to address mounting all the different directories. It's called Docker Compose.

For applications with many different containers – i.e. microservices – or even one container and different volumes mounted this can be very useful. To start an entire application can be as simple as docker compose up. Where you specify all directories in a Docker-Compose config instead and perhaps supply some as env variables.

For reproducibility, on end-user computers that is definitely the best option. If one runs this on the cluster, docker compose does not work with apptainer, so one has to manually provide the arguments again - but that sound fine for someone on a cluster.

@pawel-czyz
Copy link
Member Author

Wow, wonderful to know – I'll take a closer look at Docker Compose, then! Thanks a lot @gordonkoehn! 🙂

@pawel-czyz pawel-czyz marked this pull request as draft February 14, 2025 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants