Dockerfile, readme to config

This commit is contained in:
Adphi 2020-11-21 12:09:47 +01:00
parent a2b67cd2b6
commit 70ae746982
5 changed files with 23 additions and 10 deletions

View File

@ -1,4 +1,4 @@
FROM golang:alpine
FROM golang:alpine as builder
WORKDIR /go/go.adphi.net/go-repo
@ -6,3 +6,16 @@ COPY go.mod .
RUN go mod download
COPY . .
RUN go build -o go-repo .
FROM alpine
RUN apk add ca-certificates
COPY --from=builder /go/go.adphi.net/go-repo/go-repo /usr/bin/
EXPOSE 8888
ENTRYPOINT ["/usr/bin/go-repo"]

2
go.mod
View File

@ -4,9 +4,9 @@ go 1.14
require (
github.com/fsnotify/fsnotify v1.4.9
github.com/ghodss/yaml v1.0.0
github.com/gomarkdown/markdown v0.0.0-20200609195525-3f9352745725
github.com/sirupsen/logrus v1.6.0
github.com/spf13/cobra v1.1.1
go.uber.org/multierr v1.5.0
gopkg.in/yaml.v2 v2.2.8
)

4
go.sum
View File

@ -108,8 +108,10 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxv
github.com/konsorten/go-windows-terminal-sequences v1.0.3 h1:CE8S1cTafDpPvMhIxNJKvHsGVBgn1xWYf1NbHQhywc8=
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
@ -275,6 +277,7 @@ golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtn
golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5 h1:hKsoRgsbwY1NafxrwTs+k64bikrLBkAgPir1TNCj3Zs=
golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc h1:NCy3Ohtk6Iny5V/reW2Ktypo4zIpWBdRJ1uFMjBxdg8=
golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
@ -300,6 +303,7 @@ google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiq
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=

View File

@ -86,7 +86,5 @@ func main() {
}
cmd.Flags().StringVarP(&address, "address", "a", ":8888", "The server address")
cmd.Flags().StringVar(&level, "logs-level", "info", "")
if err := cmd.Execute(); err != nil {
logrus.Fatal(err)
}
cmd.Execute()
}

View File

@ -5,15 +5,14 @@ import (
"html/template"
"io/ioutil"
"net/http"
"os"
"path"
"strings"
"sync"
"github.com/ghodss/yaml"
"github.com/gomarkdown/markdown"
"github.com/gomarkdown/markdown/parser"
"go.uber.org/multierr"
"gopkg.in/yaml.v2"
)
var (
@ -57,13 +56,12 @@ func (m *Module) LoadReadme() error {
}
func NewModules(path string) (Modules, error) {
f, err := os.Open(path)
b, err := ioutil.ReadFile(path)
if err != nil {
return nil, err
}
defer f.Close()
c := &Config{}
if err := yaml.NewDecoder(f).Decode(c); err != nil {
if err := yaml.Unmarshal(b, c); err != nil {
return nil, err
}
return c.Modules, nil