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
43 changes: 43 additions & 0 deletions app_go/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Go artifacts
*.exe
*.exe~
*.dll
*.so
*.dylib
*.test
*.out
*.o
*.prof
*.trace
vendor/
__pycache__/

# Git
.git/
.gitignore

# IDE
.vscode/
.idea/
*.swp
*.swo

# OS
.DS_Store
Thumbs.db

# Documentation
*.md
docs/
README.md

# Docker
Dockerfile*
docker-compose*
.dockerignore

# Temporary files
*.tmp
*.log
tmp/
logs/
42 changes: 42 additions & 0 deletions app_go/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Stage 1: Builder - full build environment
FROM golang:1.21-alpine AS builder

# Install system dependencies for build (git for go mod download)
RUN apk add --no-cache git ca-certificates

# Set working directory
WORKDIR /app

# Copy Go module files
COPY go.mod ./

# Download Go module dependencies
RUN go mod download

# Copy application source code
COPY . .

# Build Go application with optimizations
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
-a \
-ldflags="-w -s -extldflags '-static'" \
-o devops-info-service .

# Stage 2: Minimal runtime
FROM scratch

# Copy CA certificates from builder for HTTPS support
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/

# Copy the compiled binary from builder
COPY --from=builder /app/devops-info-service /app/devops-info-service

# Expose port
EXPOSE 5000

# Set environment variables
ENV HOST=0.0.0.0
ENV PORT=5000

# Run the application
CMD ["/app/devops-info-service"]
97 changes: 97 additions & 0 deletions app_go/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# DevOps Info Service (Go)
## Overview
A Go-based web service designed to furnish details about itself and its operational environment. This compiled version of the service is optimized for containerization and multi-stage Docker builds, offering improved performance and smaller deployment footprints compared to interpreted languages.

## Prerequisites
- Go 1.21 or higher
- Git (for dependency management)

## Installation
1. Clone repository:

```bash
# Clone the project
git clone https://github.com/s3rap1s/DevOps-Core-Course.git
cd DevOps-Core-Course/app_go

# Download dependencies
go mod download

# Build the application
go build -o devops-info-service
```

## Running the Application
```bash
# Default configuration
./devops-info-service

# With custom port
PORT=8080 ./devops-info-service

# With custom port and host
HOST=127.0.0.1 PORT=3000 ./devops-info-service

# Run directly without building
go run main.go
Building for Different Platforms
bash
# Build for current platform
go build -o devops-info-service
```

## API Endpoints
### GET /
Return comprehensive service and system information:

```json
{
"service": {
"name": "devops-info-service",
"version": "1.0.0",
"description": "DevOps course info service",
"framework": "Go"
},
"system": {
"hostname": "my-laptop",
"platform": "linux",
"platform_version": "Linux Kernel",
"architecture": "amd64",
"cpu_count": 8,
"go_version": "go1.21.4"
},
"runtime": {
"uptime_seconds": 3600,
"uptime_human": "1 hour, 0 minutes",
"current_time": "2026-01-07T14:30:00.000Z",
"timezone": "UTC"
},
"request": {
"client_ip": "127.0.0.1:12345",
"user_agent": "curl/7.81.0",
"method": "GET",
"path": "/"
},
"endpoints": [
{"path": "/", "method": "GET", "description": "Service information"},
{"path": "/health", "method": "GET", "description": "Health check"}
]
}
```

### GET /health
Simple health endpoint for monitoring:

```json
{
"status": "healthy",
"timestamp": "2024-01-15T14:30:00.000Z",
"uptime_seconds": 3600
}
```

## Configuration
| Variable | Default | Description |
| -------- | --------- | ---------------------------- |
| `HOST` | `0.0.0.0` | Network interface to bind |
| `PORT` | `5000` | Port to listen on |
18 changes: 18 additions & 0 deletions app_go/docs/GO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Language Justification
## My Choice: Go
I selected **Go** as the compiled language for the bonus task implementation. Here's why:

**Comparison Table:**

| Criteria | Go | Rust | Java | C# |
|----------|----|------|------|----|
|Learning Curve | Low | High | Medium | Medium |
|Development Speed | High | Low | Medium | Medium |
|Standard Library | Excellent | Good | Extensive | Extensive |
|Performance | Excellent | Outstanding | Good | Good |
|Binary Size | ~7 MB | ~3 MB | ~40 MB | ~30 MB |
|Memory Safety | GC | Compile-time | GC | GC |
| **Choice for Bonus** | **✓** | | | |

**Justification:**
Go offers the perfect balance for a DevOps service: it compiles to a single static binary with no runtime dependencies, has excellent concurrency support, and provides a rich standard library including HTTP server functionality. Its simplicity and fast compilation make it ideal for the iterative development required in this course. Go is also widely used in the DevOps ecosystem (Docker, Kubernetes, Prometheus), making it a relevant choice.
Loading