Giter Club home page Giter Club logo

static-serv's Introduction

static-serv

Build Status Go Report Card

Static files http server.

Allows to serve application static files separately.
Or you can just serve static site. Has simple caching^ resource expiration is 60 seconds, GC each 30 seconds.

Configuration

Application supports configuration via environment variables:

export STATIC_ROOT=/storage
export PREFIX=/static
export PORT=8000

Installation

With docker

$> docker pull freundallein/staticserv:latest

With source

$> git clone [email protected]:freundallein/static-serv.git
$> cd static-serv
$> make build

Usage

Docker-compose

version: "3.5"

networks:
  network:
    name: example-network
    driver: bridge

services:
  gateway:
    image: "traefik:latest"
    container_name: "gateway"
    command:
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"

      - "--serversTransport.forwardingTimeouts.dialTimeout=5s"

      - "--entrypoints.web.address=:80"
      - "--entryPoints.web.transport.respondingTimeouts.readTimeout=5"
      - "--entryPoints.web.transport.respondingTimeouts.writeTimeout=5"
      - "--entryPoints.web.transport.respondingTimeouts.idleTimeout=5"
    networks: 
      - network
    ports:
      - 127.0.0.1:80:80
      - 127.0.0.1:8080:8080
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro

  staticserv:
    image: freundallein/staticserv:latest
    container_name: staticserv
    restart: always
    environment: 
      - PORT=8000
      - STATIC_ROOT=/storage
      - PREFIX=/static
    networks: 
      - network
    expose: 
      - 8000
    labels:
      - "traefik.enable=true"

      - "traefik.http.routers.static.rule=Host(`127.0.0.1`)&&PathPrefix(`/static`)"
      - "traefik.http.routers.static.entrypoints=web"

      - "traefik.http.services.static.loadbalancer.healthcheck.interval=1s"
      - "traefik.http.services.static.loadbalancer.healthcheck.path=/healthz"
      - "traefik.http.services.static.loadbalancer.healthcheck.timeout=5s"
    volumes:
      - static-files:/storage

  whoami:
    image: containous/whoami:latest
    container_name: whoami
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.whoami.rule=Host(`127.0.0.1`)"
      - "traefik.http.routers.whoami.entrypoints=web"
    networks: 
      - network

  bootstrap:
    image: freundallein/bootstrap:4.4.1
    container_name: bootstrap
    restart: always
    networks: 
      - network
    volumes:
      - static-files:/data

volumes:
    static-files:

All requests to 127.0.0.1/static/* will be served by staticserv container, otherwise by whoami.

You can mount docker volume or host here:

volumes:
  - static-files:/storage

static-serv's People

Contributors

freundallein avatar

Watchers

James Cloos avatar  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.