๐น Challenges & Exploration โ
You as a student need to fill in these assignments and learning goals by yourself. At the start of each next chapter the lecturer will, together with class, review these in an overall sense but will not give the full, word-by-word, solution for you to simply sit back and download. So it is important that you have completed the work yourself before the review starts in class and you can correct where needed.
You are not allowed to use AI like ChatGPT or Bing Copilot on the exam, but you are here! Leverage these new tools to speed up and give structure to your notes and documents. For example, ask to put material in Markdown format!
๐ After completing these challenges, you should be able to:
- Define what is DevOps Culture and why it is important for a company.
- Summarize main aspects of DevOps Culture.
- List some positive outcomes of adopting a DevOps Culture.
- Describe some strategies for implementing a DevOps Culture.
- Explain the difference between the -slim and -alpine versions of the python base image and why they are useful for minimizing container size.
- Define what is SAST (Static Application Security Testing) and how it differs from DAST (Dynamic Application Security Testing).
- Compare and contrast SonarQube Cloud and SonarQube as SAST tools for analyzing code quality and security.
๐ What is DevOps Culture? โ
We have look at DevOps from perspective of tools and the lifecycle, but another important aspect is a DevOps Culture in the company.
Watch ๐บ this video and summarize the main aspects of DevOps Culture, what positive things they bring to the company and how one would implement a culture like that.
๐ Putting Python in a Pipeline โ
You are tasked with creating a Dockerfile and a GitHub Action workflow pipeline for a FastAPI Python API that generates random numbers.
The developers have given you the following code to put into a main.py file:
from fastapi import FastAPI
from random import randint
app = FastAPI()
@app.get("/")
async def get_random_percentage():
return {'percentage': randint(0, 100)}And then given you the following dependencies in a requirements.txt file:
fastapi>=0.68.0,<0.69.0
pydantic>=1.8.0,<2.0.0
uvicorn>=0.15.0,<0.16.0You can follow these steps as a lead:
- Create a folder on your system to create the
main.pyand therequirements.txtfiles - Create a
Dockerfilein the folder as well. Start from thepython:3.10.0-alpinebase image. Go to thepythonofficial Docker Hub image page and scroll down to Image Variants to learn more about the-slimand-alpineversions. You should be able to describe them. - Test your
Dockerfilewith adocker buildanddocker runcommand. Check the result at localhost:8000. For now you can name your imagepython-api-devops. - Create a new GitHub repository for your files.
- Create a
workflow.ymlthat:- Runs on each
push - Has a job named
testthat usesflake8to check the code quality of themain/pyfile. Usuallyflake8is a tool installed usingpip. - Has a job named
deliverythat builds the container and pushes it to your own Docker Hub account. Make sure this job only runs when thetestjob completes successfully.
- Runs on each
- Push your files to your repository. Don't forget your needed GitHub Secrets.
- Edit the
main.pycode if thetestjob fails due toflake8finding errors.
๐งช More testing options: SAST โ
In the examples we have used simple tools or Actions to check or test code. Now you will look into a more advanced tool that can be categorized as a SAST tool, called SonarQube Cloud.

Follow these steps:
- Look up what SAST is. Then also look up what the alternative called DAST is.
- Look up what SonarQube and SonarQube Cloud is.
- Sign up at SonarQube Cloud here with your GitHub and use your own personal account as a SonarCloud Organisation if asked. As you can see private repositories are on a 14-day trail, but analyzing public repositories are free.
- Click the plus + sign at the top right and analyze a new project.
- Go to your GitHub and set the
website-testrepository we used in the examples to Public if it isn't already. - Analyze a new project on SonarCloud, select the
website-testrepository and click Set up to the right. Be sure to set it to Previous version to have your code checked on every change for our test. - Check the result of the first analysis. Look at the SonarQube Cloud issue categories: Security, Maintainability, Reliability and Security Hotspots.
- Make a change in the a file of the
website-testrepository and push it. - Check your
website-testproject in SonarQube Cloud again. There should be a new analysis.
