1
0

Initial Commit

This commit is contained in:
Tony Grosinger 2019-12-26 09:55:55 -08:00
commit 05a3e147f1
Signed by: tgrosinger
GPG Key ID: 065559ACE0A9C69C
7 changed files with 68 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
bin

6
Dockerfile Normal file
View File

@ -0,0 +1,6 @@
FROM scratch
MAINTAINER Tony Grosinger <tony@grosinger.net>
COPY bin/simple-file-server /
EXPOSE 80
ENTRYPOINT ["/simple-file-server"]

8
Makefile Normal file
View File

@ -0,0 +1,8 @@
.PHONY: simple-file-server
simple-file-server:
CGO_ENABLED=0 go build -o bin/simple-file-server cmd/server/main.go
.PHONY: docker-container
docker-container:
docker build -t tgrosinger/simple-file-server$(DOCKER_IMAGE_TAG) .

8
README.md Normal file
View File

@ -0,0 +1,8 @@
# Simple File Server
A single binary, running the [built-in Go file
server](https://golang.org/pkg/net/http/#FileServer).
No other features. No other security holes.
Does not serve index.html files.

23
cmd/server/main.go Normal file
View File

@ -0,0 +1,23 @@
package main
import (
"flag"
"fmt"
"net/http"
"os"
)
func main() {
root := flag.String("root", "", "Root of the static files to serve")
flag.Parse()
if root == nil || *root == "" {
flag.PrintDefaults()
os.Exit(1)
}
fmt.Println("Starting file server in", *root)
dir := http.Dir(*root)
fmt.Println(http.ListenAndServe(":80", http.FileServer(dir)))
}

19
docker-compose.yml Normal file
View File

@ -0,0 +1,19 @@
version: '3'
services:
server:
image: "tgrosinger/simple-file-server"
restart: "always"
networks:
- traefik_default
command: "-root=/data"
labels:
- "traefik.port=80"
- "traefik.frontend.rule=<FRONTEND RULE>"
- "traefik.frontend.headers.SSLRedirect=true"
- "traefik.docker.network=traefik_default"
- "traefik.enable=true"
volumes:
- <DATA DIRECTORY>:/data
networks:
traefik_default:
external: true

3
go.mod Normal file
View File

@ -0,0 +1,3 @@
module github.com/tgrosinger.simple-file-server
go 1.13