DEV Community

ranms25
ranms25

Posted on • Edited on

OSDC-2023-assignment6

This week we started learning a new and fascinating subject "Doker".
We reviewed what a "Docker" image is and saw how to set up a development environment with its help.

Source of all the slides

With the help of what we learned we got a task: Setup the local development environment open source projects - in your preferred programming language - for me, Python is my preferred programming language :).
The task was a bit complex and took some time, because it was important for me to find suitable projects that did not have a description for setting up a development environment using Docker, to install and adjust the environment according to what we envisioned in class, as well as to also run tests that the environment that was uploaded is indeed normal and good.

Setting up a development environment with Docker for mobility

  • Make sure you have Docker installed on your machine.
  • Clone the repository to your local machine using Git. For example, you can run the following command in your terminal: git clone https://github.com/mobility-team/mobility.git
  • Navigate to the project directory: cd mobility
  • Create a Docker container:

For Windows:

CMD:
docker run -it --name mobility-dev -w /opt -v %cd%:/opt python:3.9 bash

PowerShell:
docker run -it --name mobility-dev -w /opt -v ${PWD}:/opt python:3.9 bash

For Linux:
docker run -it --name mobility-dev -w /opt -v $(PWD):/opt python:3.9 bash

  • Install the required dependencies: pip install -r requirements.txt && pip install -e .
  • Install the pytest package: pip install pytest
  • Run the unit tests to make sure everything is working properly: pytest
  • Starts a Docker container docker container start -i mobility-dev

Setting up a development environment with Docker for Cosmo-Tech

  • Make sure you have Docker installed on your machine.
  • Clone the repository to your local machine using Git. For example, you can run the following command in your terminal: git clone https://github.com/Cosmo-Tech/CosmoTech-Acceleration-Library.git
  • Navigate to the project directory: cd CosmoTech-Acceleration-Library
  • Create a Docker container:

For Windows:

CMD:
docker run -it --name cosmotech-acceleration-library-dev -w /opt -v %cd%:/opt python:3.11 bash

PowerShell:
docker run -it --name cosmotech-acceleration-library-dev -w /opt -v ${PWD}:/opt python:3.11 bash

For Linux:
docker run -it --name cosmotech-acceleration-library-dev -w /opt -v $(PWD):/opt python:3.11 bash

  • Install the required dependencies: pip install -r requirements.txt
  • Install the pytest package: pip install pytest
  • Run the unit tests to make sure everything is working properly: pytest
  • Starts a Docker container docker container start -i cosmotech-acceleration-library-dev

Setting up a development environment with Docker for PHX

  • Make sure you have Docker installed on your machine.
  • Clone the repository to your local machine using Git. For example, you can run the following command in your terminal: git clone https://github.com/PH-Tools/PHX.git
  • Navigate to the project directory: cd PHX
  • Create a Docker container:

For Windows:

CMD:
docker run -it --name phx-dev dev -w /opt -v %cd%:/opt python:3.7 bash

PowerShell:
docker run -it --name phx-dev -w /opt -v ${PWD}:/opt python:3.7 bash

For Linux:
docker run -it --name phx-dev -w /opt -v $(PWD):/opt python:3.7 bash

  • Install the required dependencies: pip install -r dev-requirements.txt && pip install -e .
  • Run the unit tests to make sure everything is working properly: pytest
  • Starts a Docker container docker container start -i phx-dev

Setting up a development environment with Docker for pymx2

  • Make sure you have Docker installed on your machine.
  • Clone the repository to your local machine using Git. For example, you can run the following command in your terminal: git clone https://github.com/vpaeder/pymx2.git
  • Navigate to the project directory: cd pymx2
  • Create a Docker container: docker run -it --name pymx2-dev -v /opt/pymx2 -v /$(pwd):/opt python:3.11 bash
  • Install the required dependencies: python -m setup install
  • Run the unit tests to make sure everything is working properly: python -m unittest
  • Starts a Docker container docker container start -i pymx2-dev

Setting up a development environment with Docker for cybrid-api-id-python

  • Make sure you have Docker installed on your machine.
  • Clone the repository to your local machine using Git. For example, you can run the following command in your terminal: git clone https://github.com/Cybrid-app/cybrid-api-id-python.git
  • Navigate to the project directory: cd cybrid-api-id-python
  • Create a Docker container:

For Windows:

CMD:
docker run -it --name cybrid-api-id-python-dev -w /opt -v %cd%:/opt python:3.11 bash

PowerShell:
docker run -it --name cybrid-api-id-python-dev -w /opt -v ${PWD}:/opt python:3.11 bash

For Linux:
docker run -it --name cybrid-api-id-python-dev -w /opt -v $(PWD):/opt python:3.11 bash

  • Install the required dependencies: pip install -r requirements.txt && pip install pytest
  • Run the unit tests to make sure everything is working properly: pytest
  • Starts a Docker container docker container start -i cybrid-api-id-python-dev

The search took a long time, and so did the installation.
Because, There are projects I've seen that have a description of the installation, and for some of them it was sometimes difficult to understand how to set up an environment, and if I was able to set up then the tests they wanted were not good and did not pass, I tried to also find projects that would really want to use Docker.

I wrote in the PR the following reasons why I think it is important to add the above information:

  1. Ease of onboarding: new contributors or developers joining the project may not be familiar with the required software and libraries needed to develop and run the project. Providing clear instructions on how to set up a local development environment using Docker, it makes it easier for them to get up and running quickly.

  2. Reproducibility: By using Docker to set up the local development environment, it ensures that all developers are using the same development environment with the same versions of software and libraries. This makes it easier to reproduce bugs and issues reported by other developers, as well as ensure that the project is built and tested in a consistent manner across different environments.

  3. Isolation: Docker allows developers to create a containerized environment that is isolated from the host system, preventing potential conflicts with other software installed on the host. This helps ensure that the project's dependencies do not conflict with other software, potentially causing issues or breaking the development environment

Additionally, I sent to Open source project in Docker which is managed by @szabgab these projects as a PR to add slides and examples in this case for Python projects.

Note:
About pymx2 PR.
This PR has been written for git-scm.
The maintainer reviewed my contribution, they declined it, citing technical reasons related to the driver needing access to a serial port and the driver not being meant to be a standalone app. I realized that Dockerizing the driver may not be feasible, as it requires access to a physical device that cannot be accessed from within a Docker container.

Through this experience, I learned that not all contributions may be suitable for every project, and it is important to understand the technical requirements and design considerations of a project before making contributions (I did try to do this and it takes a lot of time and I tried to choose suitable projects, and I hope to improve on this in the future). I also gained a better understanding of the limitations of Docker and how it may not be the best option for certain types of applications, particularly those that require access to hardware devices like serial ports.

In conclusion, while my pull request was declined, I appreciate the feedback from the maintainer and the opportunity to learn more about the project and its technical requirements. I will continue to contribute to open-source projects and keep these lessons in mind in the future.

Hopefully, we will get into Docker in the next lesson and dive deeper.

Top comments (0)