Added Scratch Build with goembed FS
This commit is contained in:
parent
73ec092eb2
commit
4e0aa64d93
2 changed files with 16 additions and 5 deletions
|
@ -1,4 +1,4 @@
|
|||
FROM golang:alpine
|
||||
FROM golang:alpine as builder
|
||||
|
||||
RUN apk add --no-cache gcc libgo
|
||||
|
||||
|
@ -6,6 +6,10 @@ WORKDIR /go/src/git.ucode.space/goshorly
|
|||
COPY . .
|
||||
|
||||
RUN go get -d -v ./...
|
||||
RUN go build -o app .
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app .
|
||||
|
||||
|
||||
FROM scratch as production
|
||||
WORKDIR /goshorly
|
||||
copy --from=builder /go/src/git.ucode.space/goshorly/app /goshorly/app
|
||||
CMD ["./app"]
|
11
main.go
11
main.go
|
@ -1,6 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"log"
|
||||
"net/http"
|
||||
"regexp"
|
||||
|
@ -14,10 +15,16 @@ import (
|
|||
)
|
||||
|
||||
func main() {
|
||||
engine := html.NewFileSystem(http.Dir("./views"), ".html")
|
||||
|
||||
//go:embed views/*
|
||||
var viewsfs embed.FS
|
||||
|
||||
engine := html.NewFileSystem(http.FS(viewsfs), ".html")
|
||||
|
||||
app := fiber.New(fiber.Config{
|
||||
Views: engine,
|
||||
CaseSensitive: true,
|
||||
ServerHeader: "goshorly",
|
||||
Views: engine,
|
||||
})
|
||||
|
||||
client := redis.NewClient(&redis.Options{
|
||||
|
|
Loading…
Reference in a new issue