This commit is contained in:
parent
3adc7c0e79
commit
43adaf56b9
23
.drone.yml
Normal file
23
.drone.yml
Normal file
@ -0,0 +1,23 @@
|
||||
kind: pipeline
|
||||
name: default
|
||||
|
||||
workspace:
|
||||
base: /go
|
||||
path: src/deadbeef.codes/steven/deadbeef.codes-publicfileserver
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
image: golang
|
||||
pull: always
|
||||
environment:
|
||||
GOOS: linux
|
||||
GOARCH: amd64
|
||||
CGO_ENABLED: 0
|
||||
commands:
|
||||
- go version
|
||||
- go get
|
||||
- go build -a -ldflags '-w'
|
||||
- name: publish
|
||||
image: plugins/docker
|
||||
settings:
|
||||
repo: registry.deadbeef.codes/deadbeef.codes-publicfileserver
|
4
Dockerfile
Normal file
4
Dockerfile
Normal file
@ -0,0 +1,4 @@
|
||||
FROM scratch
|
||||
COPY deadbeef.codes-publicfileserver /
|
||||
EXPOSE 8080:8080
|
||||
ENTRYPOINT ["/deadbeef.codes-publicfileserver"]
|
23
main.go
Normal file
23
main.go
Normal file
@ -0,0 +1,23 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/signal"
|
||||
)
|
||||
|
||||
// http server setup and routing
|
||||
func main() {
|
||||
stop := make(chan os.Signal, 1)
|
||||
signal.Notify(stop, os.Interrupt)
|
||||
go func() {
|
||||
http.Handle("/public/", http.StripPrefix("/public/", http.FileServer(http.Dir("public"))))
|
||||
log.Fatal(http.ListenAndServe(":8080", nil))
|
||||
}()
|
||||
log.Println("started public fileserver on 8080")
|
||||
|
||||
<-stop
|
||||
fmt.Println("Shutting server down...")
|
||||
}
|
Loading…
Reference in New Issue
Block a user