Giter Site home page Giter Site logo

phred / smolboi Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pierrez/gostatic

0.0 1.0 0.0 7.58 MB

A kinda smol static web server for containers and Nix ๐Ÿ“ผ remix of goStatic

License: GNU General Public License v2.0

Go 71.39% Dockerfile 10.78% Nix 17.83%

smolboi's Introduction

๐Ÿ“ผ smolboi ๐Ÿ“ผ

A mixtape ๐Ÿ“ผ of the greatest hits from goStatic with a little special sauce all my my own.

The goals

  • Wafer thin OCI image
  • Aerogel weight Nix build
  • Handle the boring-ass job of serving my website to my 2 visitors a week (a guess, thanks for reading if you do!). At present I don't track metrics on this and I hope I have >0 visitors.

The original project's goal was "to create to smallest docker container for my web static files." I'm tired of Docker and want something smaller, and simpler, if I can get it. What is a Docker image but an executable tarfile?

So far I have added virtualhost support and have been running my site on it for a couple years now.

I run this on fly.io with a container image I push to GitHub's Container repository. A ~5mb web server layer combined with a ~17mb static file layer makes for very quick builds and deploys. There's not much to go wrong.

Wait, can I use this code?

Go for it, take my changes and make your own remix. What you do with that code is up to you. I'm not going to add any features that aren't related to making my webspace cooler.

Features

  • A fully static web server embedded in a SCRATCH image
  • No framework
  • Web server built for Docker
  • Light container
  • ๐Ÿ†• Virtual Hosting
  • ๐Ÿ†• custom 404 pages--create a page called 404.html at the site root, it gets served for missing pages.

Deleted or remixed features:

  • Custom response headers per path and filetype
  • Basic authentication
  • Optional Healthcheck--/health is always enabled.
  • ๐Ÿ†• Request logs always enabled
  • ๐Ÿ†• nix flake -- try nix run github:phred/smolboi -- -path ~/to/your/static/public_html

Why?

Because Caddy2 is too complex, and I don't want to configure yet another instance of Apache or Nginx. I like Deno, but I like Go's production-grade standard library HTTP server better. Rust is cool but makes fat binaries too. Go also makes fat binaries, but this project has a minimal set of dependencies

The world is full of terrible, bloated software, fat containers, node_modules by the truckload. Big binaries have hidden externalities in transport, storage, compute time, energy costs. My needs are simple and they fit in a single binary, as things should.

Thank you, PierreZ, for showing me the way. Software complexity will eat us all, best to only use what you need for the job.

How to use

docker run -d -p 80:8043 -v /path/to/website:/srv/http --name smolboi ghcr.io/phred/smolboi:latest

Usage

Usage of ./smolboi:
  -log-level string
      default: info - What level of logging to run, info logs all requests (error, warn, info, debug) (default "info")
  -path string
      The path for the static files (default "/srv/http")
  -port int
      The listening port (default 8043)
  -vhost string
      The prefix for locating lightweight virtual hosted subdomains, or vhosts. E.g. 'labs' will serve the files at /srv/http/labs/tango when someone visits http://tango.your.tld (default "labs")

Build

I think this works, give it a whirl

docker buildx create --use --name=cross
docker buildx build --platform=linux/amd64,linux/arm64,linux/arm/v5,linux/arm/v6,linux/arm/v7,darwin/amd64,darwin/arm64,windows/amd64 .

I got tired of running Docker on my Mac so I let GitHub Workflows build the phred/smolboi containers. My current container workflow builds only linux/amd64,linux/arm64,darwin/arm64.

nix

This includes a flake.nix to get started. nix run, nix develop, nix shell all work as expected.

smolboi's People

Contributors

aiomaster avatar antoniofagardo avatar codepope avatar deranjer avatar dimitor115 avatar geshan avatar gomlgs avatar jessebluemr avatar konradhoeffner avatar marinacodes avatar meredrica avatar mgurov avatar nigelsim avatar phartenfeller avatar phred avatar pierrez avatar solaris765 avatar teohrt avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.