about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEmile <hanemile@protonmail.com>2020-04-30 20:05:27 +0200
committerEmile <hanemile@protonmail.com>2020-04-30 20:05:27 +0200
commit25bbfaa9dc7a56e7df27bfe8e42a772286ffff74 (patch)
treea353712a13afc324b270926075d5ff689189f52d
parent7e7ac716629206a75ce308c775ab2c6eeeaaaa52 (diff)
super simple minimal setup
-rw-r--r--Dockerfile17
-rw-r--r--README.md25
-rwxr-xr-xfaila2bin0 -> 8091659 bytes
-rw-r--r--go.mod8
-rw-r--r--go.sum10
-rw-r--r--main.go28
6 files changed, 87 insertions, 1 deletions
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..a66e4fc
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,17 @@
+FROM golang:1.14 as build-env
+
+WORKDIR /go/src/app
+ADD . /go/src/app
+
+ENV PATH="$GOPATH/bin:$PATH"
+ENV GOBIN="$GOPATH/bin"
+RUN go env
+
+
+RUN go get -d -v ./...
+RUN go build -o /go/bin/faila2 ./...
+
+FROM gcr.io/distroless/base
+COPY --from=build-env /go/bin/faila2 /
+
+ENTRYPOINT ["/faila2"]
\ No newline at end of file
diff --git a/README.md b/README.md
index 4ef9637..4706872 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,26 @@
 # faila2
 
-faila, but simpler. Throw this binary in a folder and it'll be hosted
\ No newline at end of file
+faila, but simpler. Throw this binary in a folder and it'll be hosted
+
+## Flags
+
+```bash
+$ ./faila2 -h
+Usage of faila2:
+  -dir string
+        path to host (default "./")
+  -ip string
+        ip to listen on (default "0.0.0.0")
+  -p string
+        port to listen on (default "8087")
+```
+
+## Redirects
+
+If you want to redirect to another page, create an `index.html` in the folder that should redirect with the following content:
+
+```html
+<meta http-equiv="refresh" content="N; URL=/testb">
+```
+
+replacing `/testb` with the place where you'd like to be redirected to
diff --git a/faila2 b/faila2
new file mode 100755
index 0000000..8d801cf
--- /dev/null
+++ b/faila2
Binary files differdiff --git a/go.mod b/go.mod
new file mode 100644
index 0000000..92f9e1f
--- /dev/null
+++ b/go.mod
@@ -0,0 +1,8 @@
+module git.darknebu.la/emile/faila2
+
+go 1.13
+
+require (
+	github.com/gorilla/mux v1.7.4
+	github.com/sirupsen/logrus v1.5.0
+)
diff --git a/go.sum b/go.sum
new file mode 100644
index 0000000..7ea0499
--- /dev/null
+++ b/go.sum
@@ -0,0 +1,10 @@
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/gorilla/mux v1.7.4 h1:VuZ8uybHlWmqV03+zRzdwKL4tUnIp1MAQtp1mIFE1bc=
+github.com/gorilla/mux v1.7.4/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
+github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/sirupsen/logrus v1.5.0 h1:1N5EYkVAPEywqZRJd7cwnRtCb6xJx7NH3T3WUTF980Q=
+github.com/sirupsen/logrus v1.5.0/go.mod h1:+F7Ogzej0PZc/94MaYx/nvG9jOFMD2osvC3s+Squfpo=
+github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
+golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc=
+golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
diff --git a/main.go b/main.go
new file mode 100644
index 0000000..de5d97f
--- /dev/null
+++ b/main.go
@@ -0,0 +1,28 @@
+package main
+
+import (
+	"flag"
+	"fmt"
+	"log"
+	"net/http"
+
+	"github.com/gorilla/mux"
+)
+
+func main() {
+
+	// define the flags
+	ip := flag.String("ip", "0.0.0.0", "ip to listen on")
+	port := flag.String("p", "8087", "port to listen on")
+	dir := flag.String("dir", "./", "path to host")
+	flag.Parse()
+
+	// define the http server
+	r := mux.NewRouter()
+	r.Handle("/", http.FileServer(http.Dir(*dir)))
+	httpServer := http.Server{
+		Addr:    fmt.Sprintf("%s:%s", *ip, *port),
+		Handler: r,
+	}
+	log.Fatal(httpServer.ListenAndServe())
+}