Skip to content

Simple, production ready, HTTP server for static file serving

License

Notifications You must be signed in to change notification settings

sundowndev/serve

Repository files navigation

serve

action Go Report Card release

Lightweight, simple, production ready HTTP server for static file serving.

Installation

# Download the archive
$ curl -L "https://github.com/sundowndev/serve/releases/download/v1.1.0/serve_$(uname -s)_$(uname -m).tar.gz" -o serve.tar.gz

# Extract the binary
$ tar xfv serve.tar.gz

# Run the software
$ ./serve -h

# You can install it globally
$ mv ./serve /usr/bin/serve

If the installation fails, it probably means your OS/arch is not suppored.

Please check the output of echo "$(uname -s)_$(uname -m)" in your terminal and see if it's available on the GitHub release page.

Usage

Here's the help message :

$ serve -h

Usage of http_server:
  -addr string
    	The address to listen to.
  -port string
    	The port to listen to.
  -prefix string
    	The URI prefix path.
  -root string
    	the directory to serve files from.

Launch a HTTP server to serve files in the current directory :

$ serve -root . -port 8080 

Docker image

Launch a HTTP server to serve files in the public directory :

$ docker run -it --rm -v $PWD/public:/app/public:ro -p 80:80 sundowndev/serve -root public

Using compose

version: '3.7'

services:
    serve:
      container_name: serve
      restart: on-failure
      image: sundowndev/serve:latest
      command: "-root ./public"
      volumes:
        - ./fixtures:/app/public:ro
      ports:
        - "80:80"

License

This project is MIT Licensed.