mirror of https://github.com/statping/statping
				
				
				
			revert removed sass
							parent
							
								
									5a2afd9672
								
							
						
					
					
						commit
						b9bf873e22
					
				| 
						 | 
				
			
			@ -10,7 +10,6 @@
 | 
			
		|||
- Modified Service chart on index page to show ping data along with latency
 | 
			
		||||
- Added AWS SNS Notifier
 | 
			
		||||
- Modified dashboard services UI
 | 
			
		||||
- Removed sass dependency, now generates css from scss directly from go
 | 
			
		||||
 | 
			
		||||
# 0.90.63 (08-17-2020)
 | 
			
		||||
- Modified build process to use xgo for all arch builds
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,12 +5,14 @@ FROM alpine:latest
 | 
			
		|||
RUN apk --no-cache add libgcc libstdc++ ca-certificates curl jq && update-ca-certificates
 | 
			
		||||
 | 
			
		||||
COPY --from=base /go/bin/statping /usr/local/bin/
 | 
			
		||||
COPY --from=base /root/sassc/bin/sassc /usr/local/bin/
 | 
			
		||||
COPY --from=base /usr/local/share/ca-certificates /usr/local/share/
 | 
			
		||||
 | 
			
		||||
WORKDIR /app
 | 
			
		||||
VOLUME /app
 | 
			
		||||
 | 
			
		||||
ENV IS_DOCKER=true
 | 
			
		||||
ENV SASS=/usr/local/bin/sassc
 | 
			
		||||
ENV STATPING_DIR=/app
 | 
			
		||||
ENV PORT=8080
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,6 +20,11 @@ RUN apk add --update --no-cache libstdc++ gcc g++ make git autoconf \
 | 
			
		|||
    libtool ca-certificates linux-headers wget curl jq && \
 | 
			
		||||
    update-ca-certificates
 | 
			
		||||
 | 
			
		||||
WORKDIR /root
 | 
			
		||||
RUN git clone https://github.com/sass/sassc.git
 | 
			
		||||
RUN . sassc/script/bootstrap && make -C sassc -j4
 | 
			
		||||
# sassc binary: /root/sassc/bin/sassc
 | 
			
		||||
 | 
			
		||||
WORKDIR /go/src/github.com/statping/statping
 | 
			
		||||
ADD go.mod go.sum ./
 | 
			
		||||
RUN go mod download
 | 
			
		||||
| 
						 | 
				
			
			@ -36,4 +41,5 @@ RUN make clean generate embed
 | 
			
		|||
RUN go build -a -ldflags "-s -w -extldflags -static -X main.VERSION=${VERSION} -X main.COMMIT=${COMMIT}" -o statping --tags "netgo linux" ./cmd
 | 
			
		||||
RUN chmod a+x statping && mv statping /go/bin/statping
 | 
			
		||||
# /go/bin/statping - statping binary
 | 
			
		||||
# /root/sassc/bin/sassc - sass binary
 | 
			
		||||
# /statping - Vue frontend (from frontend)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										5
									
								
								Makefile
								
								
								
								
							
							
						
						
									
										5
									
								
								Makefile
								
								
								
								
							| 
						 | 
				
			
			@ -21,14 +21,14 @@ test: clean compile
 | 
			
		|||
	go test -v -p=1 -ldflags="-X main.VERSION=${VERSION} -X main.COMMIT=${COMMIT}" -coverprofile=coverage.out ./...
 | 
			
		||||
 | 
			
		||||
build: clean
 | 
			
		||||
	go build -a -ldflags "-s -w -extldflags -static -X main.VERSION=${VERSION} -X main.COMMIT=${COMMIT}" -o statping --tags "netgo linux" ./cmd
 | 
			
		||||
	CGO_ENABLED=1 go build -a -ldflags "-s -w -extldflags -static -X main.VERSION=${VERSION} -X main.COMMIT=${COMMIT}" -o statping --tags "netgo osusergo" ./cmd
 | 
			
		||||
 | 
			
		||||
go-build: clean
 | 
			
		||||
	rm -rf source/dist
 | 
			
		||||
	rm -rf source/rice-box.go
 | 
			
		||||
	wget https://assets.statping.com/source.tar.gz
 | 
			
		||||
	tar -xvf source.tar.gz
 | 
			
		||||
	go build -a -ldflags "-s -w -extldflags -static -X main.VERSION=${VERSION} -X main.COMMIT=${COMMIT}" -o statping --tags "netgo" ./cmd
 | 
			
		||||
	go build -a -ldflags "-s -w -extldflags -static -X main.VERSION=${VERSION} -X main.COMMIT=${COMMIT}" -o statping --tags "netgo osusergo" ./cmd
 | 
			
		||||
 | 
			
		||||
lint:
 | 
			
		||||
	go fmt ./...
 | 
			
		||||
| 
						 | 
				
			
			@ -76,6 +76,7 @@ test-deps:
 | 
			
		|||
	go get github.com/GeertJohan/go.rice/rice
 | 
			
		||||
	go get github.com/mattn/go-sqlite3
 | 
			
		||||
	go install github.com/mattn/go-sqlite3
 | 
			
		||||
	go install github.com/wellington/go-libsass
 | 
			
		||||
 | 
			
		||||
deps:
 | 
			
		||||
	go get -d -v -t ./...
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										2
									
								
								go.mod
								
								
								
								
							
							
						
						
									
										2
									
								
								go.mod
								
								
								
								
							| 
						 | 
				
			
			@ -20,6 +20,7 @@ require (
 | 
			
		|||
	github.com/pelletier/go-toml v1.7.0 // indirect
 | 
			
		||||
	github.com/pkg/errors v0.9.1
 | 
			
		||||
	github.com/prometheus/client_golang v1.1.0
 | 
			
		||||
	github.com/shopspring/decimal v1.2.0 // indirect
 | 
			
		||||
	github.com/sirupsen/logrus v1.5.0
 | 
			
		||||
	github.com/spf13/afero v1.2.2 // indirect
 | 
			
		||||
	github.com/spf13/cast v1.3.1 // indirect
 | 
			
		||||
| 
						 | 
				
			
			@ -30,6 +31,7 @@ require (
 | 
			
		|||
	github.com/stretchr/testify v1.5.1
 | 
			
		||||
	github.com/t-tiger/gorm-bulk-insert/v2 v2.0.1
 | 
			
		||||
	github.com/wellington/go-libsass v0.9.2
 | 
			
		||||
	github.com/wellington/sass v0.0.0-20160911051022-cab90b3986d6
 | 
			
		||||
	golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
 | 
			
		||||
	golang.org/x/net v0.0.0-20200625001655-4c5254603344 // indirect
 | 
			
		||||
	golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										4
									
								
								go.sum
								
								
								
								
							
							
						
						
									
										4
									
								
								go.sum
								
								
								
								
							| 
						 | 
				
			
			@ -523,6 +523,8 @@ github.com/sacloud/libsacloud v1.26.1/go.mod h1:79ZwATmHLIFZIMd7sxA3LwzVy/B77uj3
 | 
			
		|||
github.com/sacloud/libsacloud v1.36.1 h1:tCpFjWsvu/2Im8/SDmRZ49SttVXy7nHerobRc1LU9pI=
 | 
			
		||||
github.com/sacloud/libsacloud v1.36.1/go.mod h1:P7YAOVmnIn3DKHqCZcUKYUXmSwGBm3yS7IBEjKVSrjg=
 | 
			
		||||
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
 | 
			
		||||
github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=
 | 
			
		||||
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
 | 
			
		||||
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
 | 
			
		||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
 | 
			
		||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
 | 
			
		||||
| 
						 | 
				
			
			@ -599,6 +601,8 @@ github.com/vultr/govultr v0.3.3 h1:fVaF4h9u3VzTXxFsxvgBUCiM52EiahLqAPkizamLzYM=
 | 
			
		|||
github.com/vultr/govultr v0.3.3/go.mod h1:TUuUizMOFc7z+PNMssb6iGjKjQfpw5arIaOLfocVudQ=
 | 
			
		||||
github.com/wellington/go-libsass v0.9.2 h1:6Ims04UDdBs6/CGSVK5JC8FNikR5ssrsMMKE/uaO5Q8=
 | 
			
		||||
github.com/wellington/go-libsass v0.9.2/go.mod h1:mxgxgam0N0E+NAUMHLcu20Ccfc3mVpDkyrLDayqfiTs=
 | 
			
		||||
github.com/wellington/sass v0.0.0-20160911051022-cab90b3986d6 h1:qPS12y9iMXyKr2flmOG7RgiyUGkQxQibp1hx7uug9IQ=
 | 
			
		||||
github.com/wellington/sass v0.0.0-20160911051022-cab90b3986d6/go.mod h1:ncYBwTYUjmb7N+sZbf8WJYynLivoqFL+U2f8uOX2Yzk=
 | 
			
		||||
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
 | 
			
		||||
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
 | 
			
		||||
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,13 +4,12 @@ package source
 | 
			
		|||
//go:generate go run generate_version.go
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"bytes"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"github.com/GeertJohan/go.rice"
 | 
			
		||||
	"github.com/pkg/errors"
 | 
			
		||||
	"github.com/statping/statping/utils"
 | 
			
		||||
	"github.com/wellington/go-libsass"
 | 
			
		||||
	"os"
 | 
			
		||||
	"os/exec"
 | 
			
		||||
	"path/filepath"
 | 
			
		||||
	"strings"
 | 
			
		||||
)
 | 
			
		||||
| 
						 | 
				
			
			@ -59,28 +58,30 @@ func scssRendered(name string) string {
 | 
			
		|||
 | 
			
		||||
// CompileSASS will attempt to compile the SASS files into CSS
 | 
			
		||||
func CompileSASS() error {
 | 
			
		||||
	scssFile := filepath.Join(utils.Params.GetString("STATPING_DIR"), "assets", "scss", "index.scss")
 | 
			
		||||
	indexCSS := filepath.Join(utils.Params.GetString("STATPING_DIR"), "assets", "scss", "index.css")
 | 
			
		||||
	partials := filepath.Join(utils.Params.GetString("STATPING_DIR"), "assets", "scss")
 | 
			
		||||
	sassBin := utils.Params.GetString("SASS")
 | 
			
		||||
	if sassBin == "" {
 | 
			
		||||
		bin, err := exec.LookPath("sass")
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Warnf("could not find sass executable in PATH: %s", err)
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
		sassBin = bin
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	index, err := utils.OpenFile(scssFile)
 | 
			
		||||
	scssFile := filepath.Join(utils.Params.GetString("STATPING_DIR"), "assets", "scss", "index.scss")
 | 
			
		||||
	log.Infoln(fmt.Sprintf("Compiling SASS %v into %v", scssFile, scssRendered(scssFile)))
 | 
			
		||||
 | 
			
		||||
	stdout, stderr, err := utils.Command(sassBin, scssFile, scssRendered(scssFile))
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
		log.Errorln(fmt.Sprintf("Failed to compile assets with SASS %v", err))
 | 
			
		||||
		log.Errorln(fmt.Sprintf("%s %s %s", sassBin, scssFile, scssRendered(scssFile)))
 | 
			
		||||
		return errors.Wrapf(err, "failed to compile assets, %s %s %s", err, stdout, stderr)
 | 
			
		||||
	}
 | 
			
		||||
	w := bytes.NewBuffer(nil)
 | 
			
		||||
	comp, err := libsass.New(w, bytes.NewBufferString(index))
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	if err = comp.Option(libsass.IncludePaths([]string{partials})); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	if err := comp.Run(); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	if err := utils.SaveFile(indexCSS, w.Bytes()); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
 | 
			
		||||
	if stdout != "" || stderr != "" {
 | 
			
		||||
		log.Infoln(fmt.Sprintf("out: %v | error: %v", stdout, stderr))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Infoln("SASS Compiling is complete!")
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -470,7 +470,7 @@ func TestServices(t *testing.T) {
 | 
			
		|||
		item, err := Find(1)
 | 
			
		||||
		require.Nil(t, err)
 | 
			
		||||
		amount := item.Downtime().Seconds()
 | 
			
		||||
		assert.Equal(t, "75", fmt.Sprintf("%0.f", amount))
 | 
			
		||||
		assert.Equal(t, "76", fmt.Sprintf("%0.f", amount))
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	t.Run("Test Failures Since", func(t *testing.T) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue