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 docker compose file #940

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

benmalef
Copy link
Contributor

@benmalef benmalef commented Sep 13, 2024

Fixes #875

Proposed Changes

  • Add compose.yaml file. It is another way to manage and run commands in the docker.

You can check ref

you can run

docker compose up

to build and run your container

Checklist

  • CONTRIBUTING guide has been followed.
  • PR is based on the current GaNDLF master .
  • Non-breaking change (does not break existing functionality): provide as many details as possible for any breaking change.
  • Function/class source code documentation added/updated (ensure typing is used to provide type hints, including and not limited to using Optional if a variable has a pre-defined value).
  • Code has been blacked for style consistency and linting.
  • If applicable, version information has been updated in GANDLF/version.py.
  • If adding a git submodule, add to list of exceptions for black styling in pyproject.toml file.
  • Usage documentation has been updated, if appropriate.
  • Tests added or modified to cover the changes; if coverage is reduced, please give explanation.
  • If customized dependency installation is required (i.e., a separate pip install step is needed for PR to be functional), please ensure it is reflected in all the files that control the CI, namely: python-test.yml, and all docker files [1,2,3].
  • The logging library is being used and no print statements are left.

Copy link
Contributor

MLCommons CLA bot All contributors have signed the MLCommons CLA ✍️ ✅

@benmalef benmalef changed the title add docker-compose file add docker compose file Sep 13, 2024
@sarthakpati
Copy link
Collaborator

Looks good, but should we not be using this for all Docker builds?

@benmalef
Copy link
Contributor Author

Looks good, but should we not be using this for all Docker builds?

It's the same with this, IMO but in an easier way.
You can modify the compose.yaml. You can choose the dockerfile, the volume, the commands that you want to execute.

@sarthakpati
Copy link
Collaborator

Looks good, but should we not be using this for all Docker builds?

It's the same with this, IMO but in an easier way. You can modify the compose.yaml. You can choose the dockerfile, the volume, the commands that you want to execute.

Okay, then please provide clear examples of how this improves the existing docker workflow.

@benmalef
Copy link
Contributor Author

I have created an example to demonstrate how to use it, but I have noticed that extra effort is required from the user to modify the compose.yaml file.

Using the docker command line

docker run -it --rm --name dataprep \
  --volume /home/researcher/gandlf_input:/input:ro \ # input data is mounted as read-only
  --volume /home/researcher/gandlf_output:/output \ # output data is mounted as read-write
  cbica/gandlf:latest-cpu \ # change to appropriate docker image tag
  construct-csv \ # standard construct CSV API starts
  --input-dir /input/data \
  --output-file /output/data.csv \
  --channels-id _t1.nii.gz \
  --label-id _seg.nii.gz

Using the docker compose file.

version: '1'

services:
  gandlf:
    build:
      context: .
      dockerfile: Dockerfile-CPU #choose the dockerfile
#    volumes: 
#     - /home/researcher/gandlf_input:/input:to
       - /home/researcher/gandlf_output:/output
    entrypoint: ["gandlf"]
    command: ["construct-csv",
"--input-dir ","/input/data",
"--output-file ","/output/data.csv",
" --channels-id"," _t1.nii.gz ",
" --label-id", "_seg.nii.gz" ] 

You can run docker compose up to run the container and execute the command.

@sarthakpati
Copy link
Collaborator

@hasan7n since you are far more familiar with docker than I am, what are you views on this?

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.

[FEATURE] Add Docker Compose
2 participants