pull/429/head
Hunter Long 2020-02-27 22:37:48 -08:00
parent a889511c3d
commit cc6d4aa035
30 changed files with 970 additions and 5357 deletions

2
.gitignore vendored
View File

@ -31,3 +31,5 @@ dev/test/node_modules
source/scss
databases
statping
docker
tmp

View File

@ -9,10 +9,25 @@ RUN curl -L -s https://assets.statping.com/sass -o /usr/local/bin/sass && \
WORKDIR /go/src/github.com/hunterlong/statping
ADD Makefile go.mod go.sum version.txt ./
ADD go.mod go.sum version.txt ./
RUN go mod download
RUN make dev-deps
RUN go get github.com/stretchr/testify/assert && \
go get golang.org/x/tools/cmd/cover && \
go get github.com/mattn/goveralls && \
go install github.com/mattn/goveralls && \
go get github.com/rendon/testcli && \
go get github.com/robertkrimen/godocdown/godocdown && \
go get github.com/crazy-max/xgo && \
go get github.com/GeertJohan/go.rice && \
go get github.com/GeertJohan/go.rice/rice && \
go get github.com/axw/gocov/gocov && \
go get github.com/matm/gocov-html && \
go get github.com/fatih/structs && \
go get github.com/ararog/timeago && \
go get gopkg.in/natefinch/lumberjack.v2 && \
go get golang.org/x/crypto/bcrypt
ADD frontend/package.json frontend/yarn.lock ./frontend/

View File

@ -11,11 +11,20 @@ TRAVIS_BUILD_CMD='{ "request": { "branch": "master", "message": "Compile master
TEST_DIR=$(GOPATH)/src/github.com/hunterlong/statping
PATH:=/usr/local/bin:$(GOPATH)/bin:$(PATH)
up: docker-base
docker-compose -f docker-compose.yml -f dev/docker-compose.full.yml up -d --remove-orphans --build
up:
docker-compose -f docker-compose.yml -f dev/docker-compose.full.yml up -d --remove-orphans
make print_details
down:
docker-compose -f docker-compose.yml -f dev/docker-compose.full.yml down --volumes
docker-compose -f docker-compose.yml -f dev/docker-compose.full.yml down --volumes --remove-orphans
reup: down clean compose-build-full up
start:
docker-compose -f docker-compose.yml -f dev/docker-compose.full.yml start
stop:
docker-compose -f docker-compose.yml -f dev/docker-compose.full.yml stop
logs:
docker logs statping --follow
@ -23,6 +32,9 @@ logs:
console:
docker exec -t -i statping /bin/sh
compose-build-full: docker-base
docker-compose -f docker-compose.yml -f dev/docker-compose.full.yml build --parallel --build-arg VERSION=${VERSION}
docker-base:
docker build -t hunterlong/statping:base -f Dockerfile.base --build-arg VERSION=${VERSION} .
@ -76,23 +88,21 @@ clean:
find . -name "*.mem" -type f -delete
rm -rf {build,tmp,docker}
# install all required golang dependecies
dev-deps:
go get github.com/stretchr/testify/assert
go get golang.org/x/tools/cmd/cover
go get github.com/mattn/goveralls
go install github.com/mattn/goveralls
go get github.com/rendon/testcli
go get github.com/robertkrimen/godocdown/godocdown
go get github.com/crazy-max/xgo
go get github.com/GeertJohan/go.rice
go get github.com/GeertJohan/go.rice/rice
go get github.com/axw/gocov/gocov
go get github.com/matm/gocov-html
go get github.com/fatih/structs
go get github.com/ararog/timeago
go get gopkg.in/natefinch/lumberjack.v2
go get golang.org/x/crypto/bcrypt
print_details:
@echo \==== Statping Development Instance ====
@echo \Statping Vue Frontend: http://localhost:8888
@echo \Statping Backend API: http://localhost:8585
@echo \==== Statping Instances ====
@echo \Statping SQLite: http://localhost:4000
@echo \Statping MySQL: http://localhost:4005
@echo \Statping Postgres: http://localhost:4010
@echo \==== Databases ====
@echo \PHPMyAdmin: http://localhost:6000 \(MySQL database management\)
@echo \SQLite Web: http://localhost:6050 \(SQLite database management\)
@echo \PGAdmin: http://localhost:7000 \(Postgres database management \| email: admin@admin.com password: admin\)
@echo \Prometheus: http://localhost:7050 \(Prometheus Web UI\)
@echo \==== Monitoring and IDE ====
@echo \Grafana: http://localhost:3000 \(username: admin, password: admin\)
.PHONY: all build build-all build-alpine test-all test test-api docker frontend up down
.PHONY: all build build-all build-alpine test-all test test-api docker frontend up down print_details
.SILENT: travis_s3_creds

View File

@ -140,12 +140,15 @@ func CloseDB() {
// InsertCore create the single row for the Core settings in Statping
func (d *DbConfig) InsertCore() (*Core, error) {
apiKey := utils.Getenv("API_KEY", utils.NewSHA1Hash(40))
apiSecret := utils.Getenv("API_SECRET", utils.NewSHA1Hash(40))
CoreApp = &Core{Core: &types.Core{
Name: d.Project,
Description: d.Description,
ConfigFile: "config.yml",
ApiKey: utils.NewSHA1Hash(9),
ApiSecret: utils.NewSHA1Hash(16),
ApiKey: apiKey.(string),
ApiSecret: apiSecret.(string),
Domain: d.Domain,
MigrationId: time.Now().Unix(),
Config: d.DbConfig,
@ -272,8 +275,12 @@ func (d *DbConfig) Save() error {
defer config.Close()
log.WithFields(utils.ToFields(d)).Debugln("saving config file at: " + utils.Directory + "/config.yml")
CoreApp.Config = d.DbConfig
CoreApp.Config.ApiKey = utils.NewSHA1Hash(16)
CoreApp.Config.ApiSecret = utils.NewSHA1Hash(16)
apiKey := utils.Getenv("API_KEY", utils.NewSHA1Hash(16))
apiSecret := utils.Getenv("API_SECRET", utils.NewSHA1Hash(16))
CoreApp.Config.ApiKey = apiKey.(string)
CoreApp.Config.ApiSecret = apiSecret.(string)
data, err := yaml.Marshal(d)
if err != nil {
log.Errorln(err)

View File

@ -292,11 +292,15 @@ func InsertSampleHits() error {
// insertSampleCore will create a new Core for the seed
func insertSampleCore() error {
apiKey := utils.Getenv("API_KEY", "samplekey")
apiSecret := utils.Getenv("API_SECRET", "samplesecret")
core := &types.Core{
Name: "Statping Sample Data",
Description: "This data is only used to testing",
ApiKey: "sample",
ApiSecret: "samplesecret",
ApiKey: apiKey.(string),
ApiSecret: apiSecret.(string),
Domain: "http://localhost:8080",
Version: "test",
CreatedAt: time.Now().UTC(),

2209
dev/COVERAGE.html vendored

File diff suppressed because one or more lines are too long

View File

@ -1,15 +0,0 @@
FROM cypress/browsers:chrome67
LABEL maintainer="Hunter Long (https://github.com/hunterlong)"
# Statping 'test' image for running a full test using the production environment
WORKDIR $HOME/statping
ADD dev/test .
RUN npm install node-sass
ENV SASS=node-sass
RUN npm install
ADD ./statping-linux-amd64 /usr/local/bin/statping
RUN statping version
RUN npm run test-docker

26
dev/Dockerfile-demo vendored
View File

@ -1,26 +0,0 @@
FROM alpine
LABEL maintainer="Hunter Long (https://github.com/hunterlong)"
ENV STATPING_VERSION=0.80.35
RUN apk add --no-cache ca-certificates linux-headers curl
RUN curl -L -s https://assets.statping.com/sass -o /usr/local/bin/sass && \
chmod +x /usr/local/bin/sass
RUN curl -L -s https://github.com/hunterlong/statping/releases/download/v$STATPING_VERSION/statping-linux-alpine.tar.gz | tar -xz && \
chmod +x statping && mv statping /usr/local/bin/statping
ENV DB_CONN=sqlite
ENV NAME="Statping Demo"
ENV DESCRIPTION="An Awesome Demo of a Statping Server running on Docker"
ENV DOMAIN=demo.statping.com
ENV SASS=/usr/local/bin/sass
ENV IS_DOCKER=true
ENV STATPING_DIR=/app
WORKDIR /app
COPY ./dev/demo-script.sh /app/
ENTRYPOINT ./demo-script.sh

48
dev/Dockerfile.dev vendored
View File

@ -1,17 +1,47 @@
FROM golang:1.13.5-alpine as base
FROM golang:1.13.5-alpine
LABEL maintainer="Hunter Long (https://github.com/hunterlong)"
ARG VERSION
RUN apk add --no-cache libstdc++ gcc g++ make git ca-certificates linux-headers wget curl jq
RUN apk add --update --no-cache libstdc++ gcc g++ make git ca-certificates linux-headers wget curl jq libsass nodejs nodejs-npm
RUN npm install -g yarn
RUN curl -L -s https://assets.statping.com/sass -o /usr/local/bin/sass && \
chmod +x /usr/local/bin/sass
WORKDIR /go/src/github.com/hunterlong/statping
ADD . /go/src/github.com/hunterlong/statping
RUN go mod vendor
RUN make dev-deps
RUN make install
ADD go.mod go.sum version.txt ./
RUN go mod download
RUN go get github.com/stretchr/testify/assert && \
go get golang.org/x/tools/cmd/cover && \
go get github.com/mattn/goveralls && \
go install github.com/mattn/goveralls && \
go get github.com/rendon/testcli && \
go get github.com/robertkrimen/godocdown/godocdown && \
go get github.com/crazy-max/xgo && \
go get github.com/GeertJohan/go.rice && \
go get github.com/GeertJohan/go.rice/rice && \
go get github.com/axw/gocov/gocov && \
go get github.com/matm/gocov-html && \
go get github.com/fatih/structs && \
go get github.com/ararog/timeago && \
go get gopkg.in/natefinch/lumberjack.v2 && \
go get golang.org/x/crypto/bcrypt && \
go get github.com/cortesi/devd/cmd/devd && \
go get github.com/cortesi/modd/cmd/modd
ADD frontend/package.json frontend/yarn.lock ./frontend/
RUN cd frontend && yarn install --pure-lockfile --network-timeout 1000000 && \
yarn cache clean
ENV IS_DOCKER=true
ENV STATPING_DIR=/app
WORKDIR /app
ENV STATPING_DIR=/go/src/github.com/hunterlong/statping
ENV PORT=8585
EXPOSE 8585
EXPOSE 8888
CMD ["statping"]
VOLUME /go/src/github.com/hunterlong/statping
CMD /go/src/github.com/hunterlong/statping/dev/dev-env.sh

2
dev/LINT.md vendored
View File

@ -1,2 +0,0 @@
0 problems (0 errors) (0 warnings)

2601
dev/README.md vendored

File diff suppressed because one or more lines are too long

7
dev/demo-script.sh vendored
View File

@ -1,7 +0,0 @@
#!/usr/bin/env sh
COMMAND="rm -rf /app/statping.db && reboot"
echo "* * * * * echo $COMMAND >> /test_file 2>&1" > /etc/crontabs/root
statping

5
dev/dev_env.sh vendored Executable file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env sh
modd -f ./dev/modd.conf
devd -w ./src http://localhost:8585

View File

@ -1,51 +0,0 @@
version: '3.1'
volumes:
mysql_data: {}
postgres_data: {}
services:
mysql:
image: mysql:5.7
volumes:
- mysql_data:/var/lib/mysql
restart: always
ports:
- 3306:3306
environment:
MYSQL_ROOT_PASSWORD: password123
MYSQL_DATABASE: statping
MYSQL_USER: root
MYSQL_PASSWORD: password
postgres:
container_name: postgres
image: postgres:10.0-alpine
ports:
- 5432:5432
volumes:
- postgres_data:/var/lib/postgresql/data/pg_data
environment:
POSTGRES_PASSWORD: password123
POSTGRES_DB: statping
POSTGRES_USER: root
POSTGRES_PORT: 5432
PGDATA: /var/lib/postgresql/data/pg_data
phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: phpmyadmin
environment:
- PMA_HOST=mysql
- PMA_USER=root
- PMA_PASSWORD=password123
restart: always
depends_on:
- mysql
links:
- mysql
ports:
- 7474:80
volumes:
- /sessions

View File

@ -1,86 +0,0 @@
version: '2.3'
services:
statping:
container_name: statping
image: hunterlong/statping:latest
restart: always
networks:
- internet
- database
depends_on:
- postgres
volumes:
- ./statping:/app
environment:
VIRTUAL_HOST: localhost
VIRTUAL_PORT: 8080
LETSENCRYPT_HOST: ${LETSENCRYPT_HOST}
LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL}
DB_CONN: postgres
DB_HOST: postgres
DB_USER: statping
DB_PASS: password123
DB_DATABASE: statping
NAME: EC2 Example
DESCRIPTION: This is a Statping Docker Compose instance
nginx:
container_name: nginx
image: jwilder/nginx-proxy
ports:
- 0.0.0.0:80:80
- 0.0.0.0:443:443
networks:
- internet
restart: always
labels:
- "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy"
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- ./nginx/certs:/etc/nginx/certs:ro
- ./nginx/vhost:/etc/nginx/vhost.d
- ./nginx/html:/usr/share/nginx/html:ro
- ./nginx/dhparam:/etc/nginx/dhparam
environment:
DEFAULT_HOST: localhost
postgres:
container_name: postgres
image: postgres
restart: always
networks:
- database
volumes:
- ./postgres:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: password123
POSTGRES_USER: statping
POSTGRES_DB: statping
letsencrypt:
container_name: letsencrypt
image: jrcs/letsencrypt-nginx-proxy-companion
networks:
- internet
restart: always
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./nginx/certs:/etc/nginx/certs
- ./nginx/vhost:/etc/nginx/vhost.d
- ./nginx/html:/usr/share/nginx/html
- ./nginx/dhparam:/etc/nginx/dhparam
watchtower:
image: v2tec/watchtower
restart: always
volumes:
- /var/run/docker.sock:/var/run/docker.sock
command: --interval 120 --cleanup
networks:
internet:
driver: bridge
database:
driver: bridge

View File

@ -1,21 +0,0 @@
version: '3'
services:
nginx:
container_name: nginx
image: nginx:latest
restart: always
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
ports:
- 80:80
expose:
- 80
statping:
container_name: statping
image: hunterlong/statping:latest
restart: always
expose:
- 8080

View File

@ -1,62 +0,0 @@
version: '2.3'
services:
nginx:
container_name: nginx
image: jwilder/nginx-proxy
ports:
- 0.0.0.0:80:80
- 0.0.0.0:443:443
networks:
- internet
restart: always
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- ./statping/nginx/certs:/etc/nginx/certs:ro
- ./statping/nginx/vhost:/etc/nginx/vhost.d
- ./statping/nginx/html:/usr/share/nginx/html:ro
- ./statping/nginx/dhparam:/etc/nginx/dhparam
environment:
DEFAULT_HOST: localhost
statping:
container_name: statping
image: hunterlong/statping:latest
restart: always
networks:
- internet
- database
depends_on:
- postgres_statping
volumes:
- ./statping/app:/app
environment:
VIRTUAL_HOST: localhost
VIRTUAL_PORT: 8080
DB_CONN: postgres
DB_HOST: postgres_statping
DB_USER: statping
DB_PASS: password123
DB_DATABASE: statping
NAME: EC2 Example
DESCRIPTION: This is a Statping Docker Compose instance
postgres_statping:
container_name: postgres_statping
image: postgres
restart: always
networks:
- database
volumes:
- ./statping/postgres:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: password123
POSTGRES_USER: statping
POSTGRES_DB: statping
networks:
internet:
driver: bridge
database:
driver: bridge

View File

@ -1,17 +0,0 @@
version: '2.3'
services:
statping:
container_name: statping
image: hunterlong/statping:latest
restart: always
ports:
- 80:8080
volumes:
- ./statping:/app
expose:
- 8080
environment:
NAME: Statping
DESCRIPTION: You'll need to input your own Database information in Setup process

View File

@ -1,86 +0,0 @@
version: '2.3'
services:
nginx:
container_name: nginx
image: jwilder/nginx-proxy
ports:
- 0.0.0.0:80:80
- 0.0.0.0:443:443
labels:
- "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy"
networks:
- internet
restart: always
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- ./statping/nginx/certs:/etc/nginx/certs:ro
- ./statping/nginx/vhost:/etc/nginx/vhost.d
- ./statping/nginx/html:/usr/share/nginx/html:ro
- ./statping/nginx/dhparam:/etc/nginx/dhparam
environment:
DEFAULT_HOST: ${LETSENCRYPT_HOST}
letsencrypt:
container_name: letsencrypt
image: jrcs/letsencrypt-nginx-proxy-companion
networks:
- internet
restart: always
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./statping/nginx/certs:/etc/nginx/certs
- ./statping/nginx/vhost:/etc/nginx/vhost.d
- ./statping/nginx/html:/usr/share/nginx/html
- ./statping/nginx/dhparam:/etc/nginx/dhparam
statping:
container_name: statping
image: hunterlong/statping:latest
restart: always
networks:
- internet
- database
depends_on:
- postgres
volumes:
- ./statping/app:/app
environment:
VIRTUAL_HOST: ${LETSENCRYPT_HOST}
VIRTUAL_PORT: 8080
LETSENCRYPT_HOST: ${LETSENCRYPT_HOST}
LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL}
DB_CONN: postgres
DB_HOST: postgres
DB_USER: statping
DB_PASS: password123
DB_DATABASE: statping
NAME: Statping SSL Instance
DESCRIPTION: This Statping Status Page should be running ${LETSENCRYPT_HOST} with SSL.
postgres:
container_name: postgres
image: postgres
restart: always
networks:
- database
volumes:
- ./statping/postgres:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: password123
POSTGRES_USER: statping
POSTGRES_DB: statping
watchtower:
image: v2tec/watchtower
restart: always
volumes:
- /var/run/docker.sock:/var/run/docker.sock
command: --interval 120 --cleanup
networks:
internet:
driver: bridge
database:
driver: bridge

View File

@ -1,7 +1,39 @@
version: '3.7'
version: '2.3'
services:
statping_dev:
container_name: statping_dev
build:
context: ./
dockerfile: ./dev/Dockerfile.dev
args:
VERSION: DEV
COMMIT: DEV
restart: on-failure
volumes:
- ./:/go/src/github.com/hunterlong/statping
environment:
DB_CONN: sqlite
API_KEY: exampleapikey
API_SECRET: exampleapisecret
NAME: Statping on SQLite
DOMAIN: http://localhost:4000
DESCRIPTION: This is a dev environment on SQLite!
ADMIN_USER: admin
ADMIN_PASS: admin
PORT: 8585
ports:
- 8888:8888
- 8585:8585
networks:
- statping
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:8080/health || false"]
timeout: 2s
interval: 5s
retries: 10
statping:
container_name: statping
build:
@ -11,18 +43,30 @@ services:
- ./docker/statping/sqlite:/app
environment:
DB_CONN: sqlite
API_KEY: exampleapikey
API_SECRET: exampleapisecret
NAME: Statping on SQLite
DOMAIN: http://localhost:4000
DESCRIPTION: This is a dev environment on SQLite!
ADMIN_USER: admin
ADMIN_PASS: admin
ports:
- 8080:8080
- 4000:8080
networks:
- statping
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:8080/health || false"]
timeout: 2s
interval: 5s
retries: 10
statping_mysql:
container_name: statping_mysql
build:
context: ./
restart: on-failure
depends_on:
- mysql
ports:
- 8085:8080
- 4005:8080
volumes:
- ./docker/statping/mysql:/app
links:
@ -34,6 +78,23 @@ services:
DB_DATABASE: statping
DB_USER: root
DB_PASS: password123
API_KEY: exampleapikey
API_SECRET: exampleapisecret
NAME: Statping on MySQL
DOMAIN: http://localhost:4005
DESCRIPTION: This is a dev environment on MySQL!
ADMIN_USER: admin
ADMIN_PASS: admin
networks:
- statping
depends_on:
mysql:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:8080/health || false"]
timeout: 2s
interval: 5s
retries: 10
statping_postgres:
container_name: statping_postgres
@ -41,13 +102,11 @@ services:
context: ./
restart: on-failure
ports:
- 8090:8080
- 4010:8080
volumes:
- ./docker/statping/postgres:/app
links:
- postgres
depends_on:
- postgres
environment:
DB_CONN: postgres
DB_HOST: postgres
@ -55,42 +114,40 @@ services:
DB_DATABASE: statping
DB_USER: root
DB_PASS: password123
statping_latest:
container_name: statping_latest
image: hunterlong/statping:latest
restart: on-failure
volumes:
- ./docker/statping/latest:/app
environment:
DB_CONN: sqlite
ports:
- 8095:8080
statping_vue:
container_name: statping_vue
image: hunterlong/statping:vue
restart: on-failure
volumes:
- ./docker/statping/vue:/app
environment:
DB_CONN: sqlite
ports:
- 8100:8080
API_KEY: exampleapikey
API_SECRET: exampleapisecret
NAME: Statping on Postgres
DOMAIN: http://localhost:4010
DESCRIPTION: This is a dev environment on Postgres!
ADMIN_USER: admin
ADMIN_PASS: admin
networks:
- statping
depends_on:
postgres:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:8080/health || false"]
timeout: 2s
interval: 5s
retries: 10
postgres:
container_name: postgres
image: postgres:10.0-alpine
ports:
- 5432:5432
image: postgres
volumes:
- ./docker/databases/postgres:/var/lib/postgresql/data/pg_data
- ./docker/databases/postgres:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: password123
POSTGRES_DB: statping
POSTGRES_USER: root
POSTGRES_PORT: 5432
PGDATA: /var/lib/postgresql/data/pg_data
networks:
- statping
healthcheck:
test: ["CMD-SHELL", "pg_isready -U root"]
interval: 15s
timeout: 5s
retries: 5
mysql:
container_name: mysql
@ -98,36 +155,79 @@ services:
volumes:
- ./docker/databases/mysql:/var/lib/mysql
restart: always
ports:
- 3306:3306
environment:
MYSQL_ROOT_PASSWORD: password123
MYSQL_DATABASE: statping
MYSQL_USER: root
MYSQL_PASSWORD: password
networks:
- statping
healthcheck:
test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ]
timeout: 20s
interval: 15s
retries: 10
phpmyadmin:
container_name: phpmyadmin
image: phpmyadmin/phpmyadmin
restart: on-failure
depends_on:
- mysql
mysql:
condition: service_healthy
ports:
- 5050:8080
- 5050:80
links:
- mysql:db
environment:
MYSQL_ROOT_PASSWORD: password123
PMA_HOST: mysql
PMA_USER: root
PMA_PASSWORD: password123
PMA_PORT: 3306
networks:
- statping
sqlite-web:
container_name: sqlite-web
image: coleifer/sqlite-web
restart: on-failure
command: sqlite_web -H 0.0.0.0 -r -x /data/statping.db
depends_on:
statping:
condition: service_healthy
ports:
- 6050:8080
links:
- statping
volumes:
- ./docker/statping/sqlite/statping.db:/data/statping.db:ro
environment:
SQLITE_DATABASE: /data/statping.db
networks:
- statping
pgadmin4:
container_name: pgadmin4
image: fenglc/pgadmin4
restart: on-failure
environment:
DEFAULT_USER: admin@admin.com
DEFAULT_PASSWORD: admin
depends_on:
postgres:
condition: service_healthy
ports:
- 7000:5050
links:
- postgres:postgres
networks:
- statping
prometheus:
container_name: prometheus
image: prom/prometheus:v2.0.0
restart: on-failure
ports:
- 9292:9090
volumes:
- ./dev/prometheus.yml:/etc/prometheus/prometheus.yml
- ./docker/databases/prometheus:/prometheus
@ -135,14 +235,15 @@ services:
- statping
- statping_mysql
- statping_postgres
- statping_latest
- statping_vue
depends_on:
- statping_dev
ports:
- 7050:9090
networks:
- statping
- statping_mysql
- statping_postgres
- statping_latest
- statping_vue
healthcheck:
test: "/bin/wget -q -Y off http://localhost:9090/status -O /dev/null > /dev/null 2>&1"
interval: 10s
timeout: 3s
grafana:
container_name: grafana
@ -152,29 +253,23 @@ services:
- 3000:3000
volumes:
- ./docker/grafana:/var/lib/grafana
- ./dev/grafana/datasource.yml:/etc/grafana/provisioning/datasources/datasource.yml
- ./dev/grafana/dashboard.yml:/etc/grafana/provisioning/dashboards/dashboard.yml
- ./dev/grafana/statping_dashboard.json:/etc/grafana/provisioning/dashboards/statping_dashboard.json
environment:
- GF_SECURITY_ADMIN_PASSWORD=password123
- GF_USERS_ALLOW_SIGN_UP=false
- GF_AUTH_ANONYMOUS_ENABLED=true
depends_on:
- prometheus
prometheus:
condition: service_healthy
links:
- prometheus
networks:
- statping
healthcheck:
test: "/usr/bin/wget -q -Y off http://localhost:3000/api/health -O /dev/null > /dev/null 2>&1"
interval: 5s
retries: 20
vscoder:
container_name: vscoder
image: codercom/code-server
volumes:
- .:/home/coder/project
restart: always
ports:
- 7777:8080
security_opt:
- seccomp:unconfined
volumes:
mysql_data:
postgres_data:
statping_mysql:
statping_postgres:
prometheus_data:
grafana_data:
networks:
statping:

27
dev/ec2-ssl.sh vendored
View File

@ -1,27 +0,0 @@
#!/usr/bin/env bash
#
# Steps for Automatic SSL with Statping
#
# 1. Create EC2 Instance while including this file has "--data-file"
# 2. Once EC2 is created, view System Logs in EC2 instance.
# 3. In System logs, scroll all the way down and you'll see useful DNS records to use
# 4. Edit your domains DNS to point to the EC2 server.
#
## Domain for new SSL certificate and email for Lets Encrypt SSL recovery
LETSENCRYPT_HOST="status.MYDOMAIN.com"
LETSENCRYPT_EMAIL="noreply@MYEMAIL.com"
###################################################
############# Leave this part alone ###############
###################################################
exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1
printf "Statping will try to create an SSL for domain: $LETSENCRYPT_HOST\n"
printf "\nexport LETSENCRYPT_HOST=$LETSENCRYPT_HOST\n" >> /home/ubuntu/.profile
printf "export LETSENCRYPT_EMAIL=$LETSENCRYPT_EMAIL\n" >> /home/ubuntu/.profile
sudo printf "\nexport LETSENCRYPT_HOST=$LETSENCRYPT_HOST\n" >> /root/.profile
sudo printf "export LETSENCRYPT_EMAIL=$LETSENCRYPT_EMAIL\n" >> /root/.profile
source /home/ubuntu/.profile
sudo /bin/bash -c "source /root/.profile"
LETSENCRYPT_HOST=$LETSENCRYPT_HOST LETSENCRYPT_EMAIL=$LETSENCRYPT_EMAIL /home/ubuntu/init.sh

11
dev/grafana/dashboard.yml Normal file
View File

@ -0,0 +1,11 @@
apiVersion: 1
providers:
- name: 'Prometheus'
orgId: 1
folder: ''
type: file
disableDeletion: false
editable: true
options:
path: /etc/grafana/provisioning/dashboards

View File

@ -0,0 +1,50 @@
# config file version
apiVersion: 1
# list of datasources that should be deleted from the database
deleteDatasources:
- name: Prometheus
orgId: 1
# list of datasources to insert/update depending
# whats available in the database
datasources:
# <string, required> name of the datasource. Required
- name: Prometheus
# <string, required> datasource type. Required
type: prometheus
# <string, required> access mode. direct or proxy. Required
access: proxy
# <int> org id. will default to orgId 1 if not specified
orgId: 1
# <string> url
url: http://prometheus:9090
# <string> database password, if used
password:
# <string> database user, if used
user:
# <string> database name, if used
database:
# <bool> enable/disable basic auth
basicAuth: false
# <string> basic auth username, if used
basicAuthUser:
# <string> basic auth password, if used
basicAuthPassword:
# <bool> enable/disable with credentials headers
withCredentials:
# <bool> mark as default datasource. Max one per org
isDefault: true
# <map> fields that will be converted to json and stored in json_data
jsonData:
graphiteVersion: "1.1"
tlsAuth: false
tlsAuthWithCACert: false
# <string> json object of data that will be encrypted.
secureJsonData:
tlsCACert: "..."
tlsClientCert: "..."
tlsClientKey: "..."
version: 1
# <bool> allow users to edit datasources from the UI.
editable: true

7
dev/grafana/grafana.ini Normal file
View File

@ -0,0 +1,7 @@
[users]
# disable user signup / registration
allow_sign_up = false
[auth.anonymous]
# enable anonymous access
enabled = true

View File

@ -0,0 +1,616 @@
{
"__inputs": [
{
"name": "DS_PROMETHEUS",
"label": "prometheus",
"description": "Required Prometheus endpoint",
"type": "datasource",
"pluginId": "prometheus",
"pluginName": "Prometheus"
}
],
"__requires": [
{
"type": "grafana",
"id": "grafana",
"name": "Grafana",
"version": "5.2.1"
},
{
"type": "panel",
"id": "graph",
"name": "Graph",
"version": "5.0.0"
},
{
"type": "datasource",
"id": "prometheus",
"name": "Prometheus",
"version": "5.0.0"
},
{
"type": "panel",
"id": "singlestat",
"name": "Singlestat",
"version": "5.0.0"
}
],
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
}
]
},
"editable": true,
"gnetId": 6950,
"graphTooltip": 0,
"id": null,
"iteration": 1531455265624,
"links": [],
"panels": [
{
"cacheTimeout": null,
"colorBackground": false,
"colorValue": true,
"colors": [
"#890f02",
"rgba(237, 129, 40, 0.89)",
"rgb(72, 198, 35)"
],
"datasource": "${DS_PROMETHEUS}",
"format": "locale",
"gauge": {
"maxValue": 1,
"minValue": 0,
"show": false,
"thresholdLabels": false,
"thresholdMarkers": true
},
"gridPos": {
"h": 2,
"w": 5,
"x": 0,
"y": 0
},
"id": 6,
"interval": null,
"links": [],
"mappingType": 1,
"mappingTypes": [
{
"name": "value to text",
"value": 1
},
{
"name": "range to text",
"value": 2
}
],
"maxDataPoints": 100,
"nullPointMode": "connected",
"nullText": null,
"postfix": "",
"postfixFontSize": "50%",
"prefix": "",
"prefixFontSize": "50%",
"rangeMaps": [
{
"from": "null",
"text": "N/A",
"to": "null"
}
],
"sparkline": {
"fillColor": "rgba(31, 118, 189, 0.18)",
"full": false,
"lineColor": "rgb(31, 120, 193)",
"show": false
},
"tableColumn": "",
"targets": [
{
"expr": "statup_service_online{name=\"${service}\"}",
"format": "time_series",
"intervalFactor": 1,
"refId": "A"
}
],
"thresholds": "0,1",
"title": "",
"transparent": true,
"type": "singlestat",
"valueFontSize": "120%",
"valueMaps": [
{
"op": "=",
"text": "ONLINE",
"value": "1"
},
{
"op": "=",
"text": "OFFLINE",
"value": "0"
}
],
"valueName": "current"
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "${DS_PROMETHEUS}",
"fill": 1,
"gridPos": {
"h": 8,
"w": 19,
"x": 5,
"y": 0
},
"id": 2,
"legend": {
"avg": false,
"current": false,
"max": false,
"min": false,
"show": false,
"total": false,
"values": false
},
"lines": true,
"linewidth": 1,
"links": [],
"nullPointMode": "null",
"percentage": false,
"pointradius": 5,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "statup_service_latency{name=\"${service}\"}",
"format": "time_series",
"intervalFactor": 1,
"legendFormat": "{{name}}",
"refId": "A"
}
],
"thresholds": [],
"timeFrom": null,
"timeShift": null,
"title": "${service} Latency",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "ms",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
},
{
"cacheTimeout": null,
"colorBackground": false,
"colorValue": false,
"colors": [
"#299c46",
"rgba(237, 129, 40, 0.89)",
"#890f02"
],
"datasource": "${DS_PROMETHEUS}",
"decimals": 0,
"format": "ms",
"gauge": {
"maxValue": 500,
"minValue": 1,
"show": true,
"thresholdLabels": true,
"thresholdMarkers": true
},
"gridPos": {
"h": 7,
"w": 5,
"x": 0,
"y": 2
},
"id": 7,
"interval": null,
"links": [],
"mappingType": 1,
"mappingTypes": [
{
"name": "value to text",
"value": 1
},
{
"name": "range to text",
"value": 2
}
],
"maxDataPoints": 100,
"nullPointMode": "connected",
"nullText": null,
"postfix": "",
"postfixFontSize": "50%",
"prefix": "",
"prefixFontSize": "50%",
"rangeMaps": [
{
"from": "null",
"text": "N/A",
"to": "null"
}
],
"sparkline": {
"fillColor": "rgba(31, 118, 189, 0.18)",
"full": false,
"lineColor": "rgb(31, 120, 193)",
"show": false
},
"tableColumn": "",
"targets": [
{
"expr": "statup_service_latency{name=\"${service}\"}",
"format": "time_series",
"intervalFactor": 1,
"refId": "A"
}
],
"thresholds": "250,400",
"title": "",
"transparent": true,
"type": "singlestat",
"valueFontSize": "50%",
"valueMaps": [
{
"op": "=",
"text": "N/A",
"value": "null"
}
],
"valueName": "current"
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "${DS_PROMETHEUS}",
"fill": 1,
"gridPos": {
"h": 8,
"w": 19,
"x": 5,
"y": 8
},
"id": 8,
"legend": {
"avg": false,
"current": false,
"max": false,
"min": false,
"show": false,
"total": false,
"values": false
},
"lines": true,
"linewidth": 1,
"links": [],
"nullPointMode": "null",
"percentage": false,
"pointradius": 5,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "statup_service_response_length{name=\"${service}\"}",
"format": "time_series",
"intervalFactor": 1,
"legendFormat": "{{name}}",
"refId": "A"
}
],
"thresholds": [],
"timeFrom": null,
"timeShift": null,
"title": "${service} Response Size",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "bytes",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
},
{
"cacheTimeout": null,
"colorBackground": false,
"colorValue": false,
"colors": [
"#299c46",
"rgba(237, 129, 40, 0.89)",
"#d44a3a"
],
"datasource": "${DS_PROMETHEUS}",
"format": "locale",
"gauge": {
"maxValue": 100,
"minValue": 0,
"show": false,
"thresholdLabels": false,
"thresholdMarkers": true
},
"gridPos": {
"h": 3,
"w": 5,
"x": 0,
"y": 9
},
"id": 5,
"interval": null,
"links": [],
"mappingType": 1,
"mappingTypes": [
{
"name": "value to text",
"value": 1
},
{
"name": "range to text",
"value": 2
}
],
"maxDataPoints": 100,
"nullPointMode": "connected",
"nullText": null,
"postfix": "",
"postfixFontSize": "50%",
"prefix": "",
"prefixFontSize": "50%",
"rangeMaps": [
{
"from": "null",
"text": "N/A",
"to": "null"
}
],
"sparkline": {
"fillColor": "rgba(31, 118, 189, 0.18)",
"full": false,
"lineColor": "rgb(31, 120, 193)",
"show": false
},
"tableColumn": "",
"targets": [
{
"expr": "statup_service_status_code{name=\"${service}\"}",
"format": "time_series",
"intervalFactor": 1,
"refId": "A"
}
],
"thresholds": "",
"title": "Response Status Code",
"type": "singlestat",
"valueFontSize": "120%",
"valueMaps": [
{
"op": "=",
"text": "N/A",
"value": "null"
}
],
"valueName": "current"
},
{
"cacheTimeout": null,
"colorBackground": false,
"colorValue": false,
"colors": [
"#299c46",
"rgba(237, 129, 40, 0.89)",
"#d44a3a"
],
"datasource": "${DS_PROMETHEUS}",
"format": "bytes",
"gauge": {
"maxValue": 100,
"minValue": 0,
"show": false,
"thresholdLabels": false,
"thresholdMarkers": true
},
"gridPos": {
"h": 3,
"w": 5,
"x": 0,
"y": 12
},
"id": 4,
"interval": null,
"links": [],
"mappingType": 1,
"mappingTypes": [
{
"name": "value to text",
"value": 1
},
{
"name": "range to text",
"value": 2
}
],
"maxDataPoints": 100,
"nullPointMode": "connected",
"nullText": null,
"postfix": "",
"postfixFontSize": "50%",
"prefix": "",
"prefixFontSize": "50%",
"rangeMaps": [
{
"from": "null",
"text": "N/A",
"to": "null"
}
],
"sparkline": {
"fillColor": "rgba(31, 118, 189, 0.18)",
"full": false,
"lineColor": "rgb(31, 120, 193)",
"show": false
},
"tableColumn": "",
"targets": [
{
"expr": "statup_service_response_length{name=\"${service}\"}",
"format": "time_series",
"intervalFactor": 1,
"refId": "A"
}
],
"thresholds": "",
"title": "Response Size",
"type": "singlestat",
"valueFontSize": "80%",
"valueMaps": [
{
"op": "=",
"text": "N/A",
"value": "null"
}
],
"valueName": "current"
}
],
"schemaVersion": 16,
"style": "dark",
"tags": [],
"templating": {
"list": [
{
"allValue": null,
"current": {},
"datasource": "${DS_PROMETHEUS}",
"hide": 0,
"includeAll": false,
"label": "service",
"multi": false,
"name": "service",
"options": [],
"query": "label_values(statup_service_latency, name)",
"refresh": 1,
"regex": "",
"sort": 0,
"tagValuesQuery": "",
"tags": [],
"tagsQuery": "",
"type": "query",
"useTags": false
}
]
},
"time": {
"from": "now-6h",
"to": "now"
},
"timepicker": {
"refresh_intervals": [
"5s",
"10s",
"30s",
"1m",
"5m",
"15m",
"30m",
"1h",
"2h",
"1d"
],
"time_options": [
"5m",
"15m",
"1h",
"6h",
"12h",
"24h",
"2d",
"7d",
"30d"
]
},
"timezone": "",
"title": "Statping",
"uid": "6BzRjddmz",
"version": 25,
"description": "Monitor your websites and applications using Statping service. View more information at https://github.com/hunterlong/statping"
}

4
dev/modd.conf vendored Normal file
View File

@ -0,0 +1,4 @@
**/*.go {
prep: go build -o statping ./cmd
prep: daemon +sigterm: ./statping
}

12
dev/nginx.conf vendored
View File

@ -1,12 +0,0 @@
worker_processes 1;
events { worker_connections 1024; }
http {
server {
location / {
proxy_pass http://statping:8080;
}
listen 80;
}
}

View File

@ -1,15 +0,0 @@
# Deploy Portainer demo (demo.portainer.io) in a play-with-docker playground
#
# - Go to http://play-with-docker.com/?stack=https://raw.githubusercontent.com/portainer/portainer-demo/master/play-with-docker/docker-stack.yml
# - Login and/or Start.
# - Wait until 'Your session is ready!' and 'Close' modal.
# - Refresh (if a shell is not shown).
# - Wait until a link with text '80' is shown. It is the link to the demo.
# - Visit https://github.com/portainer/portainer to check default credentials.
#
version: '3'
services:
trigger:
image: franela/dind
command: sh -c "git clone https://github.com/portainer/portainer-demo/ && ./portainer-demo/portainer-demo.sh && tail -f /dev/null"
volumes: [ '/var/run/docker.sock:/var/run/docker.sock' ]

18
dev/prometheus.yml vendored
View File

@ -5,30 +5,24 @@ global:
scrape_configs:
- job_name: 'statping'
scrape_interval: 15s
bearer_token: 'TESTAPISECRETKEY'
bearer_token: 'exampleapisecret'
static_configs:
- targets: ['statping:8080']
- job_name: 'statping_mysql'
scrape_interval: 15s
bearer_token: 'TESTAPISECRETKEY'
bearer_token: 'exampleapisecret'
static_configs:
- targets: ['statping_mysql:8080']
- job_name: 'statping_postgres'
scrape_interval: 15s
bearer_token: 'TESTAPISECRETKEY'
bearer_token: 'exampleapisecret'
static_configs:
- targets: ['statping_postgres:8080']
- job_name: 'statping_latest'
- job_name: 'statping_dev'
scrape_interval: 15s
bearer_token: 'TESTAPISECRETKEY'
bearer_token: 'exampleapisecret'
static_configs:
- targets: ['statping_latest:8080']
- job_name: 'statping_vue'
scrape_interval: 15s
bearer_token: 'TESTAPISECRETKEY'
static_configs:
- targets: ['statping_vue:8080']
- targets: ['statping_dev:8080']

View File

@ -1,4 +1,4 @@
version: '3.7'
version: '2.3'
services: