Compare commits

..

No commits in common. "7ee67d3f2d77d7f18238a3b3e3eaaccd1a887876" and "a9caca277234797fe02c4a490d26f34a825f13ee" have entirely different histories.

6 changed files with 13 additions and 89 deletions

View File

@ -1,5 +1,5 @@
FROM golang:1.23-alpine3.20 AS go-builder
ENV GOPATH=""
FROM golang:1.23-alpine3.20 as go-builder
ENV GOPATH ""
RUN apk add git
@ -9,24 +9,8 @@ RUN go mod download
ADD ./ .
RUN go build -o ./server .
FROM hugomods/hugo:latest AS blog-builder
WORKDIR /app
RUN apk update && \
apk add git && \
git clone https://git.netflux.io/rob/netflux-blog blog && \
cd blog && \
git submodule update --init --recursive && \
hugo
FROM alpine:3.14
COPY --from=go-builder /app/server /app/server
COPY --from=blog-builder /app/blog/public /www/html
ENV NETFLUX_ROOT_PATH=/www/html
ENTRYPOINT ["/app/server"]

View File

@ -1,4 +0,0 @@
.PHONY: deploy
deploy: # build and deploy the latest version of the image.
docker build -t netfluxio/homepage:latest .
docker push netfluxio/homepage:latest

View File

@ -5,8 +5,8 @@ import (
"net/http"
)
//go:embed static/robots.txt
var robotsTxt []byte
//go:embed static/index.html
var indexPage string
type Params struct {
MatrixHostname string
@ -27,7 +27,7 @@ func New(params Params) http.Handler {
h.Handle("GET /.well-known/matrix/server", http.HandlerFunc(h.getMatrixServer))
h.Handle("GET /.well-known/matrix/client", http.HandlerFunc(h.getMatrixClient))
h.Handle("GET /robots.txt", http.HandlerFunc(h.getRobotsTxt))
h.Handle("GET /{$}", http.HandlerFunc(h.getHomepage))
h.Handle("GET /", http.FileServer(http.Dir(params.RootPath)))
return h
@ -45,8 +45,10 @@ func (h *handler) getMatrixClient(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(`{"m.homeserver": {"base_url": "` + h.params.MatrixBaseURL + `"}}`))
}
func (h *handler) getRobotsTxt(w http.ResponseWriter, r *http.Request) {
w.Header().Add("content-type", "text/plain")
func (h *handler) getHomepage(w http.ResponseWriter, r *http.Request) {
w.Header().Add("content-type", "text/html")
w.WriteHeader(http.StatusOK)
w.Write(robotsTxt)
if r.Method == http.MethodGet {
w.Write([]byte(indexPage))
}
}

View File

@ -41,14 +41,6 @@ func TestHandler(t *testing.T) {
wantStatusCode: http.StatusOK,
wantBody: `{"m.homeserver": {"base_url": "https://foo.example.com"}}`,
},
{
name: "GET /robots.txt",
method: http.MethodGet,
path: "/robots.txt",
wantContentType: "text/plain",
wantStatusCode: http.StatusOK,
wantBody: "Allow: /",
},
{
name: "GET /test.html",
method: http.MethodGet,
@ -61,15 +53,15 @@ func TestHandler(t *testing.T) {
name: "GET /",
method: http.MethodGet,
path: "/",
wantContentType: "text/html; charset=utf-8",
wantContentType: "text/html",
wantStatusCode: http.StatusOK,
wantBody: "<html>\n <head>\n <title>Homepage</title>\n </head>\n</html>\n",
wantBody: "Welcome to netflux.io",
},
{
name: "HEAD /",
method: http.MethodHead,
path: "/",
wantContentType: "text/html; charset=utf-8",
wantContentType: "text/html",
wantStatusCode: http.StatusOK,
wantBody: "",
},
@ -113,7 +105,6 @@ func TestHandler(t *testing.T) {
respBody, err := io.ReadAll(resp.Body)
require.NoError(t, err)
assert.Contains(t, string(respBody), tc.wantBody)
})
}

View File

@ -1,44 +0,0 @@
User-agent: AI2Bot
User-agent: Ai2Bot-Dolma
User-agent: Amazonbot
User-agent: anthropic-ai
User-agent: Applebot
User-agent: Applebot-Extended
User-agent: Bytespider
User-agent: CCBot
User-agent: ChatGPT-User
User-agent: Claude-Web
User-agent: ClaudeBot
User-agent: cohere-ai
User-agent: Diffbot
User-agent: DuckAssistBot
User-agent: FacebookBot
User-agent: FriendlyCrawler
User-agent: Google-Extended
User-agent: GoogleOther
User-agent: GoogleOther-Image
User-agent: GoogleOther-Video
User-agent: GPTBot
User-agent: iaskspider/2.0
User-agent: ICC-Crawler
User-agent: ImagesiftBot
User-agent: img2dataset
User-agent: ISSCyberRiskCrawler
User-agent: Kangaroo Bot
User-agent: Meta-ExternalAgent
User-agent: Meta-ExternalFetcher
User-agent: OAI-SearchBot
User-agent: omgili
User-agent: omgilibot
User-agent: PerplexityBot
User-agent: PetalBot
User-agent: Scrapy
User-agent: Sidetrade indexer bot
User-agent: Timpibot
User-agent: VelenPublicWebCrawler
User-agent: Webzio-Extended
User-agent: YouBot
Disallow: /
User-agent: *
Allow: /

View File

@ -1,5 +0,0 @@
<html>
<head>
<title>Homepage</title>
</head>
</html>