Fix Dockerfile
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

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

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 {
cfg = &gpaste.ServerConfig{
LogLevel: "INFO",
URL: "localhost:8080",
ListenAddr: ":8080",
SigningSecret: "TODO: CHANGE THIS LOL",
Store: &gpaste.ServerStoreConfig{
Type: "memory",
},
}
} else {
defer r.Close()
cfg, err = gpaste.ServerConfigFromReader(r)
if err != nil {
if err != nil { if err != nil {
return cli.Exit(err, 1) return cli.Exit(err, 1)
} }
defer f.Close() }
cfg, err := gpaste.ServerConfigFromReader(f)
if err != nil {
return cli.Exit(err, 1)
} }
// Setup loggers // Setup loggers
rootLogger := getRootLogger(cfg.LogLevel) rootLogger := getRootLogger(cfg.LogLevel)