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
73 changes: 73 additions & 0 deletions .github/workflows/python-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Python CI (Lab03)

on:
push:
branches: [ "main", "master", "lab3", "lab03" ]
paths:
- "app_python/**"
- ".github/workflows/python-ci.yml"
pull_request:
paths:
- "app_python/**"
- ".github/workflows/python-ci.yml"

concurrency:
group: python-ci-${{ github.ref }}
cancel-in-progress: true

jobs:
test-lint:
runs-on: ubuntu-latest
defaults:
run:
working-directory: app_python

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: "pip"
cache-dependency-path: "app_python/requirements.txt"

- name: Install deps
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

- name: Lint (ruff)
run: ruff check .

- name: Tests
run: pytest -q

docker-build-push:
needs: test-lint
runs-on: ubuntu-latest
if: github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'master' || github.ref_name == 'lab3' || github.ref_name == 'lab03')

steps:
- uses: actions/checkout@v4

- name: Set version (CalVer)
run: |
echo "CALVER=$(date +%Y.%m)" >> $GITHUB_ENV
echo "BUILD=${{ github.run_number }}" >> $GITHUB_ENV

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build & Push
uses: docker/build-push-action@v6
with:
context: ./app_python
file: ./app_python/Dockerfile
push: true
tags: |
${{ secrets.DOCKER_USERNAME }}/devops-info-service:${{ env.CALVER }}.${{ env.BUILD }}
${{ secrets.DOCKER_USERNAME }}/devops-info-service:latest
14 changes: 13 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
test
__pycache__/
*.py[cod]
venv/
__MACOSX/
*.log

.vscode/
.idea/

.obsidian

.DS_Store
.env
13 changes: 13 additions & 0 deletions app_go/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Build outputs
devops-info-service
*.exe
*.out

# Git / editor / OS
.git/
.DS_Store
.idea/
.vscode/

# Docs/tests not needed in image build context (optional)
docs/
35 changes: 35 additions & 0 deletions app_go/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# syntax=docker/dockerfile:1

# --- Stage 1: Builder ---
FROM golang:1.23.5-alpine3.21 AS builder

WORKDIR /src

# Cache deps first
COPY go.mod ./
RUN go mod download

# Copy source
COPY main.go ./

# Build a static binary (smaller + easier to run in minimal images)
ARG TARGETOS
ARG TARGETARCH

RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-arm64} \
go build -trimpath -ldflags="-s -w" -o /out/devops-info-service .

# --- Stage 2: Runtime (minimal, non-root) ---
FROM gcr.io/distroless/static-debian12:nonroot AS runtime

WORKDIR /app

COPY --from=builder /out/devops-info-service /app/devops-info-service

EXPOSE 8080

ENV HOST=0.0.0.0 \
PORT=8080

# distroless:nonroot already runs as nonroot
ENTRYPOINT ["/app/devops-info-service"]
53 changes: 53 additions & 0 deletions app_go/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# DevOps Info Service (Go) — Bonus Task

## Overview
A Go implementation of the DevOps Info Service. It provides two endpoints:
- `GET /` returns service/system/runtime/request information in JSON
- `GET /health` returns a simple health status JSON

## Prerequisites
- Go installed (check with `go version`)

## Run (from source)
```bash
go run .
```
By default the service listens on `0.0.0.0:8080`.

### Custom configuration

```bash
HOST=127.0.0.1 PORT=9090 go run .
```

## Build (binary)

```bash
go build -o devops-info-service
```

## Run (binary)

```bash
./devops-info-service
```

### Custom configuration (binary)

```bash
HOST=127.0.0.1 PORT=9090 ./devops-info-service
```

## API Endpoints

### GET /

```bash
curl -s http://127.0.0.1:8080/ | python -m json.tool
```

### GET /health

```bash
curl -s http://127.0.0.1:8080/health | python -m json.tool
```
Binary file added app_go/devops-info-service
Binary file not shown.
7 changes: 7 additions & 0 deletions app_go/docs/GO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Why Go (Compiled Language)

I chose Go for the compiled-language bonus task because:
- Go compiles into a single binary, which is convenient for deployment.
- It has a minimal standard library for building HTTP services (`net/http`).
- It’s fast to build and run and is commonly used in infrastructure/DevOps tooling.
- Small, self-contained binaries work well with Docker multi-stage builds in later labs.
49 changes: 49 additions & 0 deletions app_go/docs/LAB01.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# LAB01 — Bonus Task (Go)

## Implemented Endpoints
- `GET /` — returns service, system, runtime, request info + endpoints list (JSON)
- `GET /health` — returns health status + timestamp + uptime_seconds (JSON)

The JSON structure matches the Python version (same top-level fields and same key layout inside each section).

## How to Run (from source)
```bash
go run .
```
#### Test:

```bash
curl -s http://127.0.0.1:8080/ | python -m json.tool curl -s http://127.0.0.1:8080/health | python -m json.tool
```

## How to Build and Run (binary)

#### Build:

```bash
go build -o devops-info-service ls -lh devops-info-service
```

#### Run:

```bash
./devops-info-service
```

#### Test binary:

```bash
curl -s http://127.0.0.1:8080/health | python -m json.tool
```

## Screenshots

Screenshots are stored in `docs/screenshots/`:

Recommended set:
- `01-go-run.png` — running from source (`go run .`)
- `02-main-endpoint.png` — `GET /` output
- `03-health-endpoint.png` — `GET /health` output
- `04-go-build.png` — `go build` + `ls -lh` showing binary size
- `05-binary-run.png` — running compiled binary (`./devops-info-service`)
- `06-binary-health.png` — health check from binary run
Loading