Fix Dockerfile

This commit is contained in:
Torjus Håkestad 2022-01-21 18:03:49 +01:00
parent db41f565ca
commit 6822cd6bfe
2 changed files with 22 additions and 7 deletions
Dockerfile
cmd/server/actions

View File

@ -10,4 +10,5 @@ RUN go build -o gpaste-server ./cmd/server/server.go
FROM alpine:latest FROM alpine:latest
COPY --from=builder /src/gpaste /bin/gpaste COPY --from=builder /src/gpaste /bin/gpaste
COPY --from=builder /src/gpaste-server /bin/gpaste-server COPY --from=builder /src/gpaste-server /bin/gpaste-server
EXPOSE 8080
CMD ["/bin/gpaste-server"] CMD ["/bin/gpaste-server"]

View File

@ -2,6 +2,7 @@ package actions
import ( import (
"context" "context"
"io"
"net/http" "net/http"
"os" "os"
"os/signal" "os/signal"
@ -21,14 +22,27 @@ func ActionServe(c *cli.Context) error {
configPath = c.String("config") configPath = c.String("config")
} }
f, err := os.Open(configPath) var cfg *gpaste.ServerConfig
var r io.ReadCloser
r, err := os.Open(configPath)
if err != nil { if err != nil {
return cli.Exit(err, 1) cfg = &gpaste.ServerConfig{
} LogLevel: "INFO",
defer f.Close() URL: "localhost:8080",
cfg, err := gpaste.ServerConfigFromReader(f) ListenAddr: ":8080",
if err != nil { SigningSecret: "TODO: CHANGE THIS LOL",
return cli.Exit(err, 1) Store: &gpaste.ServerStoreConfig{
Type: "memory",
},
}
} else {
defer r.Close()
cfg, err = gpaste.ServerConfigFromReader(r)
if err != nil {
if err != nil {
return cli.Exit(err, 1)
}
}
} }
// Setup loggers // Setup loggers
rootLogger := getRootLogger(cfg.LogLevel) rootLogger := getRootLogger(cfg.LogLevel)