diff --git a/.travis.yml b/.travis.yml index 8ad48277..a0647756 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,7 +40,7 @@ deploy: - "build/statup-linux-arm64" - "build/statup-linux-arm7" - "build/statup-windows-x64.exe" - - "build/statup-alpine" + - "build/statup-linux-alpine" skip_cleanup: true notifications: diff --git a/Dockerfile b/Dockerfile index b793a2b4..444cf8bf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM alpine:latest ENV VERSION=v0.22 RUN apk --no-cache add ca-certificates -RUN wget https://github.com/hunterlong/statup/releases/download/$VERSION/statup-alpine && \ +RUN wget https://github.com/hunterlong/statup/releases/download/$VERSION/statup-linux-alpine && \ chmod +x statup-alpine && \ mv statup-alpine /usr/local/bin/statup WORKDIR /app diff --git a/README.md b/README.md index e3656803..471e6eab 100644 --- a/README.md +++ b/README.md @@ -38,19 +38,25 @@ LETSENCRYPT_HOST=mydomain.com \ Once your instance has started, it will take a moment to get your SSL certificate. Make sure you have a A or CNAME record on your domain that points to the IP/DNS of your server running Statup. ## Run on AWS EC2 -Running Statup on the smallest EC2 server is very quick using the AWS AMI Image: `ami-1f7c3567`. +Running Statup on the smallest EC2 server is very quick using the AWS AMI Image: `ami-84da93fc`. ```bash -aws ec2 run-instances \ - --image-id ami-1f7c3567 \ - --count 1 \ - --instance type t2.micro \ - --region us-west-2 - --key-name \ - --security-group-ids \ - --subnet-id \ - --region +ec2-run-instances --key KEYPAIR ami-84da93fc ``` +# EC2 with SSL Certificate +```bash +wget https://raw.githubusercontent.com/hunterlong/statup/master/servers/ec2-ssl.sh +# +# Edit ec2-ssl.sh and add LETSENCRYPT_HOST and LETSENCRYPT_EMAIL +# +# nano ec2-ssl.sh +# +ec2-run-instances --key KEYPAIR \ + --user-data-file ec2-ssl.sh \ + ami-bf5eb9d6 +``` + + ## Email Nofitications Statup includes email notification via SMTP if your services go offline. diff --git a/build.sh b/build.sh index c4dfc059..d287deb7 100755 --- a/build.sh +++ b/build.sh @@ -14,7 +14,7 @@ xgo -go 1.10.x --targets=windows-6.0/amd64 --dest=build -ldflags="-X main.VERSIO xgo -go 1.10.x --targets=linux/arm-7 --dest=build -ldflags="-X main.VERSION=$VERSION" ./ xgo -go 1.10.x --targets=linux/arm64 --dest=build -ldflags="-X main.VERSION=$VERSION" ./ -CGO_ENABLED=0 GOOS=linux go build -ldflags="-X main.VERSION=$VERSION" -a -o build/statup-alpine . +CGO_ENABLED=0 GOOS=linux go build -ldflags="-X main.VERSION=$VERSION" -a -o build/statup-linux-alpine . cd build ls diff --git a/failures.go b/failures.go index a37a2290..fc085390 100644 --- a/failures.go +++ b/failures.go @@ -46,8 +46,8 @@ func (u *Service) DeleteFailures() { func (s *Service) LimitedFailures() []*Failure { var fails []*Failure - col := dbSession.Collection("failures").Find("service", s.Id) - col.OrderBy("create_at").All(&fails) + col := dbSession.Collection("failures").Find("service", s.Id).OrderBy("-id").Limit(10) + col.All(&fails) return fails } diff --git a/html/tmpl/dashboard.html b/html/tmpl/dashboard.html index 41b17ac4..8f8bb557 100644 --- a/html/tmpl/dashboard.html +++ b/html/tmpl/dashboard.html @@ -44,9 +44,9 @@ {{ range .Services }} - {{ if .Failures }} + {{ if .LimitedFailures }}
- {{ range .Failures }} + {{ range .LimitedFailures }}
{{.ParseError}}
diff --git a/servers/docker-compose.yml b/servers/docker-compose.yml index 97a5103b..eda046dd 100644 --- a/servers/docker-compose.yml +++ b/servers/docker-compose.yml @@ -8,6 +8,8 @@ services: 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 @@ -18,7 +20,20 @@ services: - ./statup/nginx/html:/usr/share/nginx/html:ro - ./statup/nginx/dhparam:/etc/nginx/dhparam environment: - DEFAULT_HOST: localhost + 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 + - ./statup/nginx/certs:/etc/nginx/certs + - ./statup/nginx/vhost:/etc/nginx/vhost.d + - ./statup/nginx/html:/usr/share/nginx/html + - ./statup/nginx/dhparam:/etc/nginx/dhparam statup: container_name: statup @@ -32,15 +47,17 @@ services: volumes: - ./statup/app:/app environment: - VIRTUAL_HOST: localhost + VIRTUAL_HOST: ${LETSENCRYPT_HOST} VIRTUAL_PORT: 8080 + LETSENCRYPT_HOST: ${LETSENCRYPT_HOST} + LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL} DB_CONN: postgres DB_HOST: postgres DB_USER: statup DB_PASS: password123 DB_DATABASE: statup - NAME: EC2 Example - DESCRIPTION: This is a Statup Docker Compose instance + NAME: Statup on EC2 + DESCRIPTION: This Status Status Page should be running ${LETSENCRYPT_HOST} with SSL. postgres: container_name: postgres diff --git a/servers/ec2-ssl.sh b/servers/ec2-ssl.sh new file mode 100644 index 00000000..337edcf5 --- /dev/null +++ b/servers/ec2-ssl.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +## Domain for new SSL certificate +LETSENCRYPT_HOST="status.balancebadge.io" + +## An email address that can recover SSL certificate from Lets Encrypt +LETSENCRYPT_EMAIL="info@socialeck.com" + +################################################### +############# Leave this part alone ############### +################################################### + +printf "Statup 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 ./startup.sh diff --git a/servers/init.sh b/servers/init.sh index d377ec22..dc23a7ab 100644 --- a/servers/init.sh +++ b/servers/init.sh @@ -2,4 +2,4 @@ cd /home/ubuntu curl -o /home/ubuntu/startup.sh -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/hunterlong/statup/master/servers/startup.sh chmod +x /home/ubuntu/startup.sh -./startup.sh \ No newline at end of file +LETSENCRYPT_HOST=$LETSENCRYPT_HOST LETSENCRYPT_EMAIL=$LETSENCRYPT_EMAIL ./startup.sh \ No newline at end of file diff --git a/servers/startup-ssl.sh b/servers/startup-ssl.sh index 2ca1323c..05a1ee6f 100644 --- a/servers/startup-ssl.sh +++ b/servers/startup-ssl.sh @@ -1,9 +1,7 @@ #!/usr/bin/env bash -LETSENCRYPT_HOST="status.balancebadge.io" -LETSENCRYPT_EMAIL="info@socialeck.com" - +cd /home/ubuntu rm -f docker-compose.yml -curl -o docker-compose.yml -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/hunterlong/statu$ +curl -o docker-compose.yml -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/hunterlong/statup/master/servers/docker-compose-ssl.yml sudo service docker start sudo docker system prune -af sudo LETSENCRYPT_HOST=$LETSENCRYPT_HOST LETSENCRYPT_EMAIL=$LETSENCRYPT_EMAIL docker-compose pull diff --git a/servers/startup.sh b/servers/startup.sh index 6b54a8fb..1b59c312 100644 --- a/servers/startup.sh +++ b/servers/startup.sh @@ -4,5 +4,5 @@ rm -f docker-compose.yml curl -o docker-compose.yml -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/hunterlong/statup/master/servers/docker-compose.yml sudo service docker start sudo docker system prune -af -sudo docker-compose pull -sudo docker-compose up -d \ No newline at end of file +sudo LETSENCRYPT_HOST=$LETSENCRYPT_HOST LETSENCRYPT_EMAIL=$LETSENCRYPT_EMAIL docker-compose pull +sudo LETSENCRYPT_HOST=$LETSENCRYPT_HOST LETSENCRYPT_EMAIL=$LETSENCRYPT_EMAIL docker-compose up -d \ No newline at end of file