How to test my Dockerfile for my python project using GitHub actions?

Sometimes we make errors in writing the docker file. If there is an error in the Dockerfile, the docker build will fail.
Sometimes we may forget to specify dependencies in our Dockerfile. Let’s take an example.

Suppose, I have a python script that c…


This content originally appeared on DEV Community and was authored by Aahnik Daw

  • Sometimes we make errors in writing the docker file. If there is an error in the Dockerfile, the docker build will fail.

  • Sometimes we may forget to specify dependencies in our Dockerfile. Let's take an example.

Suppose, I have a python script that can take the screenshot of any web page (whose URL is supplied).

  • Now, in my code I am using pyppeeteer(Headless chrome/chromium automation library (unofficial port of puppeteer)
  • pyppeeteer uses chromium and chrome driver. These are already installed in my machine. So, running pytest will pass in my local dev environment.
  • I forget to specify the RUN commands in the dockerfile, that will install chromium and chrome driver. so running tests inside the container will fail. (although the docker build will succeed.)

I want to automate the task of building docker images and running tests in the container.

In the local machine, I can run docker build -t myproj . to build.

and for testing, I can run docker run -it myproj pytest (if i forget to add the RUN that installs chromium and chromedriver, then my pytest will fail inside container)

I hope I am able to explain my purpose.

Normally,in github actions,the python source code can be run on ubuntu, mac, windows etc.
Besides the different os, I also want to build and test my dockerfile.

how can I do that? Please don't give tutorials to writing github actions. I am looking for an optimized way for achieving my task. My work can be done in many ways, but looking for specific instructions from an expert.

you may answer in the comments below or here https://stackoverflow.com/questions/67134410/how-to-test-my-dockerfile-for-my-python-project-using-github-actions


This content originally appeared on DEV Community and was authored by Aahnik Daw


Print Share Comment Cite Upload Translate Updates
APA

Aahnik Daw | Sciencx (2021-04-17T03:40:23+00:00) How to test my Dockerfile for my python project using GitHub actions?. Retrieved from https://www.scien.cx/2021/04/17/how-to-test-my-dockerfile-for-my-python-project-using-github-actions/

MLA
" » How to test my Dockerfile for my python project using GitHub actions?." Aahnik Daw | Sciencx - Saturday April 17, 2021, https://www.scien.cx/2021/04/17/how-to-test-my-dockerfile-for-my-python-project-using-github-actions/
HARVARD
Aahnik Daw | Sciencx Saturday April 17, 2021 » How to test my Dockerfile for my python project using GitHub actions?., viewed ,<https://www.scien.cx/2021/04/17/how-to-test-my-dockerfile-for-my-python-project-using-github-actions/>
VANCOUVER
Aahnik Daw | Sciencx - » How to test my Dockerfile for my python project using GitHub actions?. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/04/17/how-to-test-my-dockerfile-for-my-python-project-using-github-actions/
CHICAGO
" » How to test my Dockerfile for my python project using GitHub actions?." Aahnik Daw | Sciencx - Accessed . https://www.scien.cx/2021/04/17/how-to-test-my-dockerfile-for-my-python-project-using-github-actions/
IEEE
" » How to test my Dockerfile for my python project using GitHub actions?." Aahnik Daw | Sciencx [Online]. Available: https://www.scien.cx/2021/04/17/how-to-test-my-dockerfile-for-my-python-project-using-github-actions/. [Accessed: ]
rf:citation
» How to test my Dockerfile for my python project using GitHub actions? | Aahnik Daw | Sciencx | https://www.scien.cx/2021/04/17/how-to-test-my-dockerfile-for-my-python-project-using-github-actions/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.