Skip to content

Commit

Permalink
FSN-29: Remove frontend code
Browse files Browse the repository at this point in the history
Do not look for an index.html file at startup and remove all frontend
code.
  • Loading branch information
stefanoboriero committed Jan 9, 2025
1 parent 5f509cf commit 475b9b5
Show file tree
Hide file tree
Showing 109 changed files with 2 additions and 37,287 deletions.
7 changes: 0 additions & 7 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
version: 2

updates:
- package-ecosystem: "npm"
directory: "/web"
labels:
- "dependencies"
schedule:
interval: "daily"

- package-ecosystem: "gomod"
directory: "/"
labels:
Expand Down
14 changes: 0 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
# UI build image
FROM node:16.5.0 as frontend

WORKDIR /web

COPY web/package.json web/package-lock.json /web/

RUN npm install --legacy-peer-deps

COPY web/ /web/

RUN npm run build-prod


# Build image
FROM golang:1.16-alpine3.13 AS builder

Expand Down
33 changes: 0 additions & 33 deletions internal/app/cloudinfo/api/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,17 @@
package api

import (
"fmt"
"io/fs"
"io/ioutil"
"net/http"
"strings"

"emperror.dev/emperror"
"emperror.dev/errors"
ginprometheus "github.com/banzaicloud/go-gin-prometheus"
"github.com/gin-contrib/cors"
"github.com/gin-contrib/static"
"github.com/gin-gonic/gin"

"github.com/banzaicloud/cloudinfo/internal/cloudinfo"
"github.com/banzaicloud/cloudinfo/internal/cloudinfo/metrics"
"github.com/banzaicloud/cloudinfo/internal/cloudinfo/types"
"github.com/banzaicloud/cloudinfo/internal/platform/buildinfo"
"github.com/banzaicloud/cloudinfo/internal/platform/log"
"github.com/banzaicloud/cloudinfo/web"
)

// RouteHandler configures the REST API routes in the gin router
Expand Down Expand Up @@ -68,33 +60,8 @@ func (r *RouteHandler) ConfigureRoutes(router *gin.Engine, basePath string) {
router.Use(log.Middleware())
router.Use(cors.New(corsConfig))

webFiles, _ := fs.Sub(web.Files(), "dist/web")
router.Use(static.Serve(basePath, fileSystem(webFiles)))

base := router.Group(basePath)

{
indexFile, err := webFiles.Open("index.html")
emperror.Panic(errors.WrapIf(err, "open index.html"))

indexContent, err := ioutil.ReadAll(indexFile)
emperror.Panic(err)

newIndexContent := []byte(strings.Replace(
string(indexContent),
"<base href=\"/\">",
fmt.Sprintf("<base href=\"%s/\">", basePath),
-1,
))

base.GET("/", func(c *gin.Context) {
_, _ = c.Writer.Write(newIndexContent)
})
base.GET("index.html", func(c *gin.Context) {
c.Redirect(http.StatusMovedPermanently, "./")
})
}

{
base.GET("/status", r.signalStatus)
base.GET("/version", r.versionHandler)
Expand Down
14 changes: 2 additions & 12 deletions main-targets.mk
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ config.toml:
sed 's/production/development/g; s/debug = false/debug = true/g; s/shutdownTimeout = "5s"/shutdownTimeout = "0s"/g; s/format = "json"/format = "logfmt"/g; s/level = "info"/level = "trace"/g; s/address = ":/address = "127.0.0.1:/g' config.toml.dist > config.toml

.PHONY: build
build: web-go ## Build a binary
build: ## Build a binary
ifeq (${VERBOSE}, 1)
go env
endif
Expand Down Expand Up @@ -80,7 +80,7 @@ bin/gotestsum-${GOTESTSUM_VERSION}:
TEST_PKGS ?= ./...
TEST_REPORT_NAME ?= results.xml
.PHONY: test
test: web-go
test:
test: TEST_REPORT ?= main
test: TEST_FORMAT ?= short
test: SHELL = /bin/bash
Expand Down Expand Up @@ -123,13 +123,3 @@ bin/gqlgen-${GQLGEN_VERSION}:
.PHONY: graphql
graphql: bin/gqlgen ## Generate GraphQL code
bin/gqlgen

web-go: web/dist/web/index.html web/dist/web/assets/index.html

web/dist/web/index.html:
@mkdir -p web/dist/web
@touch web/dist/web/index.html

web/dist/web/assets/index.html:
@mkdir -p web/dist/web/assets
@touch web/dist/web/assets/index.html
11 changes: 0 additions & 11 deletions web/.browserslistrc

This file was deleted.

13 changes: 0 additions & 13 deletions web/.editorconfig

This file was deleted.

46 changes: 0 additions & 46 deletions web/.gitignore

This file was deleted.

27 changes: 0 additions & 27 deletions web/README.md

This file was deleted.

Loading

0 comments on commit 475b9b5

Please sign in to comment.