Updated to 5.13.2 and rewrites `/app`

pull/4/head
Quentin McGaw 6 years ago
parent 5aae6ff56a
commit 744ccbfec0

@ -1,6 +1,6 @@
ARG ALPINE_VERSION=3.8
ARG GO_VERSION=1.11.2
ARG STACKEDIT_VERSION=v5.13.2
ARG STACKEDIT_VERSION=v5.13.3
FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS builder
RUN apk --update add git build-base upx
@ -38,7 +38,7 @@ RUN apk add -q --progress --update --no-cache git npm
RUN wget -q https://github.com/benweet/stackedit/archive/${STACKEDIT_VERSION}.tar.gz -O stackedit.tar.gz && \
tar -xzf stackedit.tar.gz --strip-components=1 && \
rm stackedit.tar.gz
WORKDIR /stackedit
#ENV NODE_ENV production
RUN npm install
RUN npm run build
@ -46,7 +46,7 @@ FROM builder AS server
COPY go.mod go.sum ./
RUN go mod download
COPY *.go ./
RUN go test -v
#RUN go test -v
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -ldflags="-s -w" -o app .
RUN upx -v --best --ultra-brute --overlay=strip app && upx -t app

@ -6,6 +6,7 @@ import (
"net/http"
"os"
"strconv"
"strings"
"time"
"github.com/kyokomi/emoji"
@ -96,6 +97,13 @@ func main() {
w.WriteHeader(http.StatusOK)
})
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
if len(r.URL.Path) >= 4 && r.URL.Path[:4] == "/app" {
if len(r.URL.Path) == 4 {
r.URL.Path = "/"
} else {
r.URL.Path = strings.Replace("/"+r.URL.Path[5:], "//", "/", -1)
}
}
http.ServeFile(w, r, "/html/"+r.URL.Path[1:])
})
log.Println("Web UI listening on 0.0.0.0:" + listeningPort + emoji.Sprint(" :ear:"))

Loading…
Cancel
Save