Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Binary file added .coverage
Binary file not shown.
71 changes: 71 additions & 0 deletions .github/workflows/python-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Python CI

on:
push:
paths:
- 'app_python/**'
pull_request:
paths:
- 'app_python/**'

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v4

- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: 3.11
cache: "pip"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r app_python/requirements.txt
pip install -r app_python/requirements-dev.txt

- name: Run linter
run: ruff check .

- name: Run pytest tests
run: |
pytest -v

- name: Install Snyk CLI
run: npm install -g snyk

- name: Run Snyk Test
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
run: snyk test app_python --severity-threshold=high


docker:
if: github.ref == 'refs/heads/main'
needs: test
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Generate version
run: echo "VERSION=$(date +%Y.%m.%d)" >> $GITHUB_ENV

- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: ./app_python
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/devops-info-service:${{ env.VERSION }}
${{ secrets.DOCKERHUB_USERNAME }}/devops-info-service:latest
15 changes: 14 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
test
# Python
__pycache__/
*.py[cod]
venv/
*.log
app_python/venv/
app_python/__pycache__/

# IDE
.vscode/
.idea/

# OS
.DS_Store
23 changes: 23 additions & 0 deletions app_go/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM golang:1.25-alpine AS builder

WORKDIR /app

COPY go.mod ./
RUN go mod download

COPY . .

RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o app

FROM alpine:3.19

WORKDIR /app

RUN adduser -D appuser
USER appuser

COPY --from=builder /app/app .

EXPOSE 5000

CMD ["./app"]
164 changes: 164 additions & 0 deletions app_go/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
# Lab01 — DevOps Info Service

## Overview

**DevOps Info Service (Go version)** is a lightweight web application written in Go that provides detailed information about the service itself, the system it runs on, and its runtime environment.

This implementation is part of the **bonus task** for Lab 01 and is intended to demonstrate the advantages of using a compiled language in DevOps workflows, especially for containerization and multi-stage Docker builds.

**Features:**

* `GET /` — returns service, system, runtime, and request information
* `GET /health` — simple health check endpoint
* Configurable via environment variables

---

## Prerequisites

* Go **1.24.5**

---

## Installation

1. Clone the repository:

```bash
git clone https://github.com/Daniil20xx/DevOps-Core-Course.git
```

2. Navigate to the Go application directory:

```bash
cd app_go
```

3. Initialize Go module (if not already initialized):

```bash
go mod init devops-info-service
```

---

## Running the Application

### Run directly

```bash
cd app_go
go run main.go
```

By default, the service runs on:

```
http://0.0.0.0:5000
```

### Run with custom configuration

```bash
HOST=127.0.0.1 PORT=8080 go run main.go
```

---

## API Endpoints

### `GET /`

Returns detailed information about the service and the system.

**Example:**

```json
{
"endpoints": [
{
"description": "Service information",
"method": "GET",
"path": "/"
},
{
"description": "Health check",
"method": "GET",
"path": "/health"
}
],
"request": {
"client_ip": "::1",
"method": "GET",
"path": "/",
"user_agent": "Mozilla/5.0 (Windows NT; Windows NT 10.0; ru-RU) WindowsPowerShell/5.1.26100.7462"
},
"runtime": {
"current_time": "2026-01-28T08:32:20Z",
"timezone": "UTC",
"uptime_human": "0 hours, 24 minutes",
"uptime_seconds": 1452
},
"service": {
"description": "DevOps course info service",
"framework": "net/http",
"name": "devops-info-service",
"version": "1.0.0"
},
"system": {
"architecture": "amd64",
"cpu_count": 16,
"go_version": "go1.24.5",
"hostname": "Daniil",
"platform": "windows",
"platform_version": "go1.24.5"
}
}
```

---

### `GET /health`

Returns service health status.

**Example:**

```bash
curl http://localhost:8080/health
```

**Response:**

```json
{
"status": "healthy",
"timestamp": "2026-01-28T08:33:26Z",
"uptime_seconds": 1518
}
```

---

## Configuration

The application can be configured using environment variables:

| Environment Variable | Default | Description |
| -------------------- | --------- | ---------------------------------- |
| `HOST` | `0.0.0.0` | Host address to bind the server |
| `PORT` | `8080` | Port to run the application on |

---

## Project Structure

```
app_go/
├── main.go
├── go.mod
├── README.md
└── docs/
├── LAB01.md
└── screenshots/
```
60 changes: 60 additions & 0 deletions app_go/docs/GO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# GO — Language Selection Justification

## Overview

For the bonus part of Lab 01, the DevOps Info Service was reimplemented using **Go**, a compiled programming language widely used in modern DevOps.
The goal of this implementation is to demonstrate the advantages of compiled languages in terms of performance, deployment, and containerization.

---

## Why Go?

Go was selected for the following reasons:

### 1. Compiled Language

Go compiles source code into a **single native binary**, which eliminates the need for a runtime interpreter (unlike Python).
This results in:

* Faster application startup
* Lower runtime overhead
* Simpler deployment process

---

### 2. Standard Library for Web Services

Go provides a powerful and production-ready HTTP server through the standard `net/http` package.
This allows building web services without relying on external frameworks, reducing dependencies and potential security risks.

---

### 3. Performance and Resource Efficiency

Compared to interpreted languages, Go applications:

* Use less memory
* Handle concurrent requests efficiently
* Scale well under load

This makes Go a popular choice for infrastructure tools, monitoring systems, and backend services.

---

## Comparison with Python Implementation

| Aspect | Python (Flask) | Go |
| --------------------- | ----------------------- | ----------------------- |
| Language Type | Interpreted | Compiled |
| Startup Time | Slower | Faster |
| Deployment | Requires Python runtime | Single binary |
| Docker Image Size | Larger | Smaller |
| Performance | Good for small services | High |
| Dependency Management | External packages | Mostly standard library |

---

## Conclusion

Go was chosen for the bonus implementation because it provides a clean, efficient, and production-ready approach to building web services.
Using Go alongside Python in this lab demonstrates the trade-offs between interpreted and compiled languages and prepares the project for future DevOps tasks such as containerization, CI/CD pipelines, and Kubernetes deployments.
Loading