Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
4cb2645
U24
vutoff Oct 16, 2024
ae1daf8
Add requirements.txt
vutoff Oct 23, 2024
63b2492
Add requirements.txt
vutoff Oct 23, 2024
05cc45a
Practice 1 Dockerfile with python
u34-georgi-telerik Oct 23, 2024
c200434
Add missing escape for the pipes
u34-georgi-telerik Oct 23, 2024
5ba9f55
Additional changes to RUN command
u34-georgi-telerik Oct 23, 2024
dc71257
Add python3-pip
u34-georgi-telerik Oct 23, 2024
69d4ef6
Add -y
u34-georgi-telerik Oct 23, 2024
01f66ac
Refactor again
u34-georgi-telerik Oct 23, 2024
e934bdd
Refactor 2
u34-georgi-telerik Oct 23, 2024
de09d4a
change port inside app.py to 5000 from 3000
u34-georgi-telerik Oct 23, 2024
6340897
Refactorring
u34-georgi-telerik Oct 23, 2024
ccf2ffe
Ansible homework
vutoff Oct 28, 2024
28b5f52
Merge branch 'practice1'
u34-georgi-telerik Oct 28, 2024
b91e922
Ansible homework
vutoff Oct 28, 2024
db04a17
Merge branch 'main' of github.com:u34-georgi-telerik/devops-programme
u34-georgi-telerik Nov 4, 2024
9c9959b
§GitHub Actions Demo
u34-georgi-telerik Nov 4, 2024
a4f488c
add lint§
u34-georgi-telerik Nov 4, 2024
5724ad4
add tests to pipeline
u34-georgi-telerik Nov 4, 2024
d63241d
changes to workflows
u34-georgi-telerik Nov 4, 2024
bde7d2b
some other adjustments
u34-georgi-telerik Nov 4, 2024
b1db746
First 3 steps for practice tasks (initial)
u34-georgi-telerik Nov 11, 2024
0d826c0
After Vutov Test 1
u34-georgi-telerik Nov 11, 2024
280b82a
indent
u34-georgi-telerik Nov 11, 2024
fd0603c
Indentation 2
u34-georgi-telerik Nov 11, 2024
9cc1cb3
Indentation 3
u34-georgi-telerik Nov 11, 2024
ebd80c8
Change syntaxis 1
u34-georgi-telerik Nov 11, 2024
f1b1c7f
Change syntaxis 2
u34-georgi-telerik Nov 11, 2024
1766c2d
Change syntaxis 3
u34-georgi-telerik Nov 11, 2024
593a336
Change syntaxis 4
u34-georgi-telerik Nov 11, 2024
813346b
Change syntaxis 5
u34-georgi-telerik Nov 11, 2024
fda9b76
Change syntaxis 6
u34-georgi-telerik Nov 11, 2024
c4d2072
Change syntaxis 7
u34-georgi-telerik Nov 11, 2024
e48845e
Change syntaxis 8
u34-georgi-telerik Nov 11, 2024
14bc815
Change syntaxis 9
u34-georgi-telerik Nov 11, 2024
3f7c731
Change syntaxis 10
u34-georgi-telerik Nov 11, 2024
c8ffb06
Change syntaxis 11
u34-georgi-telerik Nov 11, 2024
9db0033
Change syntaxis 12
u34-georgi-telerik Nov 11, 2024
994bf2e
Change syntaxis 13
u34-georgi-telerik Nov 11, 2024
bf90c37
Change syntaxis 14
u34-georgi-telerik Nov 11, 2024
d333b0b
Change syntaxis 15
u34-georgi-telerik Nov 11, 2024
3b666be
Change syntaxis 16
u34-georgi-telerik Nov 11, 2024
fc6c0b9
Change syntaxis 17
u34-georgi-telerik Nov 12, 2024
e589427
Change syntaxis 18
u34-georgi-telerik Nov 12, 2024
f5e6f26
Add unittest 1
u34-georgi-telerik Nov 12, 2024
e929bba
Add unittest 2
u34-georgi-telerik Nov 12, 2024
3438ac3
Add gitleaks 1
u34-georgi-telerik Nov 12, 2024
d9268d0
Add Sonar 1
u34-georgi-telerik Nov 12, 2024
0b2fa92
Add Sonar 2
u34-georgi-telerik Nov 12, 2024
67b1d8b
Add Sonar 3
u34-georgi-telerik Nov 12, 2024
d3a0158
Add Sonar 4
u34-georgi-telerik Nov 12, 2024
2bfa1e8
Add Sonar 5
u34-georgi-telerik Nov 12, 2024
5336c0a
Add Sonar 6
u34-georgi-telerik Nov 12, 2024
9a03442
Add Sonar 7
u34-georgi-telerik Nov 12, 2024
7c82cb1
Add Sonar 9
u34-georgi-telerik Nov 12, 2024
0b038ba
Add Snyk 1
u34-georgi-telerik Nov 12, 2024
6eee438
Add Snyk 2
u34-georgi-telerik Nov 12, 2024
41d58e3
Add Snyk 4
u34-georgi-telerik Nov 12, 2024
5f2d55a
Add Snyk 5
u34-georgi-telerik Nov 12, 2024
5831341
Add Snyk 6
u34-georgi-telerik Nov 12, 2024
f794f7b
Add Snyk 6
u34-georgi-telerik Nov 12, 2024
83e2b9d
Add Snyk 7
u34-georgi-telerik Nov 12, 2024
fd3358a
Add Snyk 8
u34-georgi-telerik Nov 12, 2024
6ebd1fd
Add Docker 1
u34-georgi-telerik Nov 12, 2024
82ff244
Add Docker 2
u34-georgi-telerik Nov 12, 2024
c9dde79
Add Docker 3
u34-georgi-telerik Nov 12, 2024
31e67da
Add Trivy 1
u34-georgi-telerik Nov 12, 2024
858e1ad
Add Trivy 2
u34-georgi-telerik Nov 12, 2024
6114a05
Create CONTRIBUTING
u34-georgi-telerik Nov 12, 2024
1ad3143
Add Optional 1
u34-georgi-telerik Nov 12, 2024
875f39b
Add Optional 2
u34-georgi-telerik Nov 12, 2024
9102d7f
Add Optional 3
u34-georgi-telerik Nov 12, 2024
0f50994
Add Optional 4
u34-georgi-telerik Nov 12, 2024
cfe9731
Add Optional 5
u34-georgi-telerik Nov 12, 2024
e1c6ce9
Add Optional 6
u34-georgi-telerik Nov 12, 2024
494e378
Add Optional 7
u34-georgi-telerik Nov 12, 2024
9d9a890
Add Optional 9
u34-georgi-telerik Nov 18, 2024
94bfdb4
Few changes for parallel run 1
u34-georgi-telerik Nov 19, 2024
3efb872
Few changes for parallel run 2
u34-georgi-telerik Nov 19, 2024
e93f6c4
Few changes for parallel run 7
u34-georgi-telerik Nov 19, 2024
53c92cc
Few changes for parallel run 8
u34-georgi-telerik Nov 19, 2024
6c044c0
pre-commit fix 1
u34-georgi-telerik Nov 19, 2024
054c344
pre-commit fix 2
u34-georgi-telerik Nov 19, 2024
aa11e47
editor-config fix 2
u34-georgi-telerik Nov 19, 2024
9c832a1
editor-config fix 3
u34-georgi-telerik Nov 19, 2024
ff9fae9
markdown-check fix 1
u34-georgi-telerik Nov 19, 2024
f3cf76d
markdown-check fix 2
u34-georgi-telerik Nov 19, 2024
6b395d6
markdown-check fix 3
u34-georgi-telerik Nov 19, 2024
4e4dbbc
markdown-check fix 4
u34-georgi-telerik Nov 19, 2024
0e28e40
markdown-check fix 5
u34-georgi-telerik Nov 19, 2024
00c4704
code-lint fix 1
u34-georgi-telerik Nov 19, 2024
728aa22
code-lint fix 2
u34-georgi-telerik Nov 19, 2024
34f93f6
code-lint fix 3
u34-georgi-telerik Nov 19, 2024
1dfff72
pre-commit optimizations 3
u34-georgi-telerik Nov 19, 2024
693fe18
pre-commit optimizations 4
u34-georgi-telerik Nov 19, 2024
343c281
pre-commit optimizations 5
u34-georgi-telerik Nov 19, 2024
67c2cd1
add snyk 1
u34-georgi-telerik Nov 19, 2024
4a4b206
add snyk 2
u34-georgi-telerik Nov 19, 2024
50d73f9
add snyk 3
u34-georgi-telerik Nov 19, 2024
45fd88b
add docker compose 1
u34-georgi-telerik Nov 19, 2024
e8c7407
add docker compose 3
u34-georgi-telerik Nov 19, 2024
2d45b9d
restructuring the repo
u34-georgi-telerik Nov 19, 2024
7b3f1c3
restructuring the repo
u34-georgi-telerik Nov 19, 2024
fee522d
restructuring the repo 3
u34-georgi-telerik Nov 19, 2024
4d2f42d
restructuring the repo 4
u34-georgi-telerik Nov 19, 2024
8135625
run on a branch
u34-georgi-telerik Nov 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# EditorConfig is awesome: https://editorconfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true

# Matches multiple files with brace expansion notation
# Set default charset
[*.{js,py}]
charset = utf-8

# 4 space indentation
[*.py]
indent_style = space
indent_size = 4

# Tab indentation (no size specified)
[Makefile]
indent_style = tab

# Indentation override for all JS under lib directory
[lib/**.js]
indent_style = space
indent_size = 2

# Matches the exact files either package.json or .travis.yml
[{package.json,.travis.yml}]
indent_style = space
indent_size = 2
195 changes: 195 additions & 0 deletions .github/workflows/ci-pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
---
name: GitHub Actions Homework Demo
run-name: ${{ github.actor }} is testing out GitHub Actions
on:
push:
branches:
- github-actions-practice

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v3
with:
python-version: '3.10'
cache: 'pip'
- name: Install pre-commit
run: |
python -m pip install pre-commit
pre-commit install
- name: Run pre-commit
run: pre-commit run --all-files

editorconfig-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Check .editorconfig exists
run: |
if [ ! -f .editorconfig ]; then
echo ".editorconfig file not found in root directory"
exit 1
fi
- name: Install editorconfig-checker
run: |
npm install -g editorconfig-checker
editorconfig-checker

secrets-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Check for hardcoded secrets
uses: gitleaks/gitleaks-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

markdown-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run markdown lint with npx
run: npx markdownlint-cli .

code-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.10'
cache: 'pip'
- name: Install linting tools
run: pip install pylint flake8 flask
- name: Lint Python code
run: |
find . -name '*.py' | xargs pylint
flake8 .

unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.10'
cache: 'pip'
- name: Run unit tests
run: |
cd app
python -m unittest discover -v

docker-build:
needs:
- pre-commit
- editorconfig-check
- secrets-check
- markdown-check
- code-lint
- unit-tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build Docker image
uses: docker/build-push-action@v2
with:
context: .
push: false
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/u34:${{ github.sha }}
${{ secrets.DOCKERHUB_USERNAME }}/u34:latest

trivy:
needs: docker-build
runs-on: ubuntu-latest
outputs:
has_critical_vulnerabilities: ${{ steps.trivy.outputs.exit_code }}
steps:
- uses: actions/checkout@v2
- name: Scan Docker image with Trivy
uses: aquasecurity/trivy-action@master
continue-on-error: true
with:
image-ref: ${{ secrets.DOCKERHUB_USERNAME }}/u34:${{ github.sha }}
format: 'table'
exit-code: '1'
ignore-unfixed: true
severity: 'CRITICAL'

snyk:
needs: docker-build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run Snyk to check for vulnerabilities
uses: snyk/actions/python@master
continue-on-error: true
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
command: test

docker-compose:
needs: docker-build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Docker Compose
run: |
BASEURL="https://github.com/docker/compose/releases/latest/download"
FILENAME="docker-compose-$(uname -s)-$(uname -m)"
sudo curl -L "${BASEURL}/${FILENAME}" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
- name: Build and Run Container with Docker Compose
run: |
docker-compose up -d --build
docker-compose ps
docker-compose logs

push-to-docker:
needs:
- trivy
- snyk
runs-on: ubuntu-latest
if: ${{ needs.trivy.outputs.has_critical_vulnerabilities == '0' }}
steps:
- uses: actions/checkout@v2
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Push Docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/u34:${{ github.sha }}
${{ secrets.DOCKERHUB_USERNAME }}/u34:latest

sonarcloud:
needs: [push-to-docker]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
6 changes: 6 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"default": true,
"MD013": {
"line_length": 120
}
}
20 changes: 20 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-merge-conflict
- id: check-added-large-files
args: ['--maxkb=500']
- id: detect-private-key

- repo: https://github.com/zricethezav/gitleaks
rev: v8.18.1
hooks:
- id: gitleaks

- repo: https://github.com/adrienverge/yamllint
rev: v1.33.0
hooks:
- id: yamllint
args: [--format, parsable, --no-warnings]
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.11.8
37 changes: 37 additions & 0 deletions CONTRIBUTING
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Contributing to U34
Thank you for your interest in contributing to U34! We welcome and appreciate all contributions, whether they are bug reports, feature requests, or code changes.

Before you start, please take a moment to review the following guidelines to ensure a smooth and effective contribution process.

## Code of Conduct

By participating in this project, you agree to abide by the [Contributor Covenant Code of Conduct](https://www.contributor-covenant.org/version/2/1/code_of_conduct/). Please familiarize yourself with the code of conduct and ensure your contributions align with it.

## How to Contribute

There are several ways you can contribute to U34:

1. **Report Bugs**: If you encounter any bugs or issues, please report them by [opening a new issue](https://github.com/u34-georgi-telerik/devops-programme/issues/new/choose) on the project's GitHub repository. Be sure to provide a clear and detailed description of the problem, including steps to reproduce the issue.

2. **Suggest Features**: Have an idea for a new feature or an improvement to an existing one? [Open a new issue](https://github.com/u34-georgi-telerik/devops-programme/issues/new/choose) and describe your proposal. We'll be happy to discuss it with you.

3. **Submit Code Changes**: If you'd like to contribute code changes, follow these steps:
- Fork the repository and create a new branch for your changes.
- Make your changes and ensure they align with the project's coding style and guidelines.
- Write tests for your changes, if applicable.
- Commit your changes and push them to your forked repository.
- [Open a pull request](https://github.com/u34-georgi-telerik/devops-programme/pulls) against the main branch of the original repository.

4. **Provide Feedback**: Even if you don't have a specific bug report or feature request, we welcome any feedback or suggestions you may have about the project. You can [open a new issue](https://github.com/u34-georgi-telerik/devops-programme/issues/new/choose) or reach out to the project maintainers directly.

## Development Environment Setup

To set up your development environment, please follow these steps:

1. Clone the repository: `git clone https://github.com/u34-georgi-telerik/devops-programme.git`
2. Install the required dependencies: `pip install -r requirements.txt`
3. Run the test suite: `pytest`

If you have any questions or need further assistance, don't hesitate to [open an issue](https://github.com/u34-georgi-telerik/devops-programme/issues/new/choose) or reach out to the project maintainers.

We look forward to your contributions and appreciate your involvement in making U34 even better!
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM ubuntu:22.04
RUN apt-get update && \
apt-get install -y \
python3 -y \
python3-pip -y && \
groupadd -g 1234 notroot && \
useradd -m -u 1234 -g notroot notroot
USER notroot
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY app .
EXPOSE 5000
CMD ["python3", "app.py"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# devops-programme
# devops-programme
33 changes: 33 additions & 0 deletions ansible/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Configuration Management with Ansible

Create an Ansible playbook that build, push and then run the Docker image for the Python
application. Let your playbook has the following variables:

* `image_name` - contains the name of your image without the tag, i.e. `vutoff/python-app`
* `image_tag` - contains the tag you tagged your image with, i.e. `v0.2`
* `listen_port` - contains the listening port you're binding your app to.

Make sure that you set environment variable `PORT` when you define your container
in the Ansible playbook that takes its value from `listen_port` variable.

Use Ansible modules. Do not shell out.

## Requirements

* Make sure you have Python installed. Any version above 3.8 would suffice.
* The `requirements.txt` file in this directory contains the required Ansible version. Run

```sh
pip install -r requirements.txt
```

* Make sure that Docker is running on your local machine.

## Mind the following

* If you're running Docker Desktop, mind the location of the `docker.sock` file. The location of the socket file is
* Docker Desktop - `${HOME}/.docker/run/docker.sock`

* If you're using one of the above, when you write your Ansible playbook you
must specify the path to the docker socket with the parameter `docker_host`,
i.e. `docker_host: "unix://{{ ansible_env.HOME }}/.rd/docker.sock"`.
Loading