Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Scratch Container - Distroless Web Server

A minimal, ultra-lightweight HTTP web server written in Go using the scratch Docker base image for production-ready containerization.

Overview

This project demonstrates a simple HTTP server built with Go and deployed using the scratch base image—the most minimal container base available. Unlike traditional distroless images (which still contain minimal utilities), scratch is completely empty: it contains nothing but your application binary. This results in the smallest possible container images with zero OS overhead.

Features

  • Barebone: Uses scratch base image—the absolute minimum container
  • Ultra-Lightweight: Typical image size: 10-20 MB (vs 800+ MB for full OS)
  • Zero Attack Surface: No OS exploits possible—no shell to exploit
  • Multi-stage Build: Compiles in Go environment, deploys minimal binary
  • Production-Ready: Secure and optimized for containerization
  • Static Binary: Go app compiled as self-contained executable

Prerequisites

To run this project, you need:

  • Go 1.25.0+ (for local development)
  • Docker (for containerized deployment)
  • Docker Compose (for orchestrated deployment)

Usage

Building the Docker Image

docker build -t go-distroless:latest .

Running with Docker

docker run -p 80:80 go-distroless:latest

Running with Docker Compose

Start the service:

docker-compose up

Stop the service:

docker-compose down

View logs:

docker-compose logs -f

Endpoints

  • GET / - Returns a simple HTML welcome page with "Hello, World!"
curl http://localhost:80
# Output: <h1>Hello, World!</h1>

Performance

The distroless approach provides:

  • Smaller Image Size: Typically 10-20 MB vs 800+ MB for full OS images
  • Reduced Attack Surface: No shell, package managers, or unnecessary utilities
  • Faster Startup: Minimal dependencies to load

License

MIT License - feel free to use this project for learning and development.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages