A lightweight, interactive Go calculator CLI app containerized using a multi-stage Docker build โ reducing image size from 854MB to just 1.9MB using the scratch base image ๐ณ๐.
This is a simple command-line calculator written in Go (calculator.go). It supports basic arithmetic operations (+, -, *, /) and takes user input in the format:
The project uses a two-stage Docker build:
- Stage 1: Compiles the Go binary using the full Golang environment.
- Stage 2: Copies only the compiled binary into a
scratchimage, resulting in an extremely small final image.
docker build -t go-calculator .
docker build -t reduced-calculator .
docker images
| Docker Image Base | Image Size |
|---|---|
ubuntu (single stage) |
854 MB |
scratch (multistage) |
1.9 MB โ |