Initial Commit
This commit is contained in:
commit
05a3e147f1
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
bin
|
6
Dockerfile
Normal file
6
Dockerfile
Normal 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
8
Makefile
Normal 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
8
README.md
Normal 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
23
cmd/server/main.go
Normal 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
19
docker-compose.yml
Normal 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
|
Loading…
Reference in New Issue
Block a user