Made generating static site possible
continuous-integration/drone/push Build is passing Details

This commit is contained in:
DutchEllie 2022-05-27 20:35:53 +02:00
parent 8aaecbab69
commit 029b426757
Signed by: DutchEllie
SSH Key Fingerprint: SHA256:UU8yhd1Bh8exU88ev0ej/Dm+CeyfR/ZIDRrpRfYdfbg
2 changed files with 7 additions and 0 deletions

View File

@ -4,14 +4,17 @@ APIURL_staging := https://api.quenten.nl/api/testing
build: build:
GOARCH=wasm GOOS=js go build -o web/app.wasm -ldflags="-X 'main.ApiURL=${APIURL_staging}'" ./src GOARCH=wasm GOOS=js go build -o web/app.wasm -ldflags="-X 'main.ApiURL=${APIURL_staging}'" ./src
go build -o app -ldflags="-X 'main.ApiURL=${APIURL_staging}'" ./src go build -o app -ldflags="-X 'main.ApiURL=${APIURL_staging}'" ./src
cp -r web staticsite/
build-new: build-new:
GOARCH=wasm GOOS=js go build -o web/app.wasm ./src GOARCH=wasm GOOS=js go build -o web/app.wasm ./src
go build -o app ./src go build -o app ./src
cp -r web staticsite/
build-prod: build-prod:
GOARCH=wasm GOOS=js go build -o web/app.wasm -ldflags="-X 'main.ApiURL=${APIURL_prod}'" ./src GOARCH=wasm GOOS=js go build -o web/app.wasm -ldflags="-X 'main.ApiURL=${APIURL_prod}'" ./src
go build -o app -ldflags="-X 'main.ApiURL=${APIURL_prod}'" ./src go build -o app -ldflags="-X 'main.ApiURL=${APIURL_prod}'" ./src
cp -r web staticsite/
run: build run: build
./app ./app

View File

@ -4,6 +4,7 @@ import (
"compress/gzip" "compress/gzip"
"log" "log"
"net/http" "net/http"
"os"
"github.com/gorilla/handlers" "github.com/gorilla/handlers"
"github.com/maxence-charriere/go-app/v9/pkg/app" "github.com/maxence-charriere/go-app/v9/pkg/app"
@ -89,6 +90,9 @@ func main() {
app.GenerateStaticWebsite("./staticsite", handler) app.GenerateStaticWebsite("./staticsite", handler)
compressed := handlers.CompressHandlerLevel(handler, gzip.BestSpeed) compressed := handlers.CompressHandlerLevel(handler, gzip.BestSpeed)
http.Handle("/", compressed) http.Handle("/", compressed)
if os.Getenv("GEN_STATIC_SITE") == "true" {
return
}
if err := http.ListenAndServe(":8000", nil); err != nil { if err := http.ListenAndServe(":8000", nil); err != nil {
log.Fatal(err) log.Fatal(err)