Feedback

Chat Icon

DevSecOps in Practice

A Hands-On Guide to Operationalizing DevSecOps at Scale

Setting Up the Foundation: The Git Setup
19%

Configuring the Git Repository

Because Git is a crucial part of the SDLC, we will create a Git repository for the application. Start by initializing a Git repository in the RestQR folder:

cd $HOME/RestQR
git init

We will create a .gitignore file to exclude any unnecessary files from the repository. We will use the Python and Terraform .gitignore files from the github/gitignore repository:

# Ignore Python unnecessary files
curl https://raw.githubusercontent.com/github/gitignore/master/Python.gitignore \
    > $HOME/RestQR/.gitignore

# Ignore Terraform unnecessary files
curl https://raw.githubusercontent.com/github/gitignore/refs/heads/main/Terraform.gitignore \
    >> $HOME/RestQR/.gitignore

Create a branch called main:

git checkout -b main

Configure the Git user:

git config --global user.email "admin@restqr.app"
git config --global user.name "RestQR"

At this stage, we have multiple options when it comes to choosing a Git repository hosting service. You can use GitHub, GitLab, Bitbucket, or any other open-source Git repository hosting service like Gitea or Gogs. For this guide, we are going to use GitLab. The choice of GitLab is based on the fact that it provides a complete solution for the SDLC, including CI/CD and Docker registry. Start by creating an account on GitLab.

Start by creating a token to authenticate with GitLab. Call it RestQR and give it the api scope. Export the token as an environment variable:

cat <>~/.bashrc && source ~/.bashrc
export GITLAB_API_TOKEN=""
EOF

Install the GitLab CLI:

# Add WakeMeOps repository
curl -sSL \
    "https://raw.githubusercontent.com/upciti/wakemeops/main/assets/install_repository" | \
    bash

# Install glab
apt install glab -y

Authenticate with GitLab:

glab auth login \
    --hostname gitlab.com \
    --token $GITLAB_API_TOKEN

Check if the authentication was successful:

glab auth status

If you are not using gitlab.com as your GitLab instance, for example, if you are using a self-hosted GitLab instance, you should adapt the command accordingly or simply run glab auth login for an interactive login.

To establish a secure connection between your server and GitLab, you need to generate an SSH key pair. Start by generating the SSH key pair:

DevSecOps in Practice

A Hands-On Guide to Operationalizing DevSecOps at Scale

Enroll now to unlock all content and receive all future updates for free.