Compare commits
4 Commits
master
...
new-health
Author | SHA1 | Date | |
---|---|---|---|
|
2313fe1d63 | ||
|
93fa6e8b12 | ||
|
dd1695b171 | ||
|
bdb454233b |
3
.gitignore
vendored
3
.gitignore
vendored
@ -16,3 +16,6 @@ dist-ssr
|
|||||||
|
|
||||||
cypress/videos
|
cypress/videos
|
||||||
cypress/screenshots
|
cypress/screenshots
|
||||||
|
|
||||||
|
/extra/healthcheck.exe
|
||||||
|
/extra/healthcheck
|
||||||
|
@ -1,3 +1,19 @@
|
|||||||
|
############################################
|
||||||
|
# Build in Golang
|
||||||
|
# Super slow for armv7 (compile time = 1200 seconds, but other platforms within 5 seconds).
|
||||||
|
# Do not change everything here, so it should always use the cache.
|
||||||
|
############################################
|
||||||
|
FROM golang:1.19.4-buster AS build_healthcheck
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY ./extra/healthcheck.go ./extra/healthcheck.go
|
||||||
|
|
||||||
|
# Compile healthcheck.go
|
||||||
|
RUN go build -x -o ./extra/healthcheck ./extra/healthcheck.go
|
||||||
|
|
||||||
|
############################################
|
||||||
|
# Build in Node.js
|
||||||
|
############################################
|
||||||
FROM louislam/uptime-kuma:base-debian AS build
|
FROM louislam/uptime-kuma:base-debian AS build
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
@ -7,24 +23,31 @@ COPY . .
|
|||||||
RUN npm ci --production && \
|
RUN npm ci --production && \
|
||||||
chmod +x /app/extra/entrypoint.sh
|
chmod +x /app/extra/entrypoint.sh
|
||||||
|
|
||||||
|
############################################
|
||||||
|
# ⭐ Main Image
|
||||||
|
############################################
|
||||||
FROM louislam/uptime-kuma:base-debian AS release
|
FROM louislam/uptime-kuma:base-debian AS release
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy app files from build layer
|
# Copy app files from build layer
|
||||||
COPY --from=build /app /app
|
COPY --from=build /app /app
|
||||||
|
COPY --from=build_healthcheck /app/extra/healthcheck /app/extra/healthcheck
|
||||||
|
|
||||||
EXPOSE 3001
|
EXPOSE 3001
|
||||||
VOLUME ["/app/data"]
|
VOLUME ["/app/data"]
|
||||||
HEALTHCHECK --interval=60s --timeout=30s --start-period=180s --retries=5 CMD node extra/healthcheck.js
|
HEALTHCHECK --interval=60s --timeout=30s --start-period=180s --retries=5 CMD extra/healthcheck
|
||||||
ENTRYPOINT ["/usr/bin/dumb-init", "--", "extra/entrypoint.sh"]
|
ENTRYPOINT ["/usr/bin/dumb-init", "--", "extra/entrypoint.sh"]
|
||||||
CMD ["node", "server/server.js"]
|
CMD ["node", "server/server.js"]
|
||||||
|
|
||||||
|
############################################
|
||||||
|
# Mark as Nightly
|
||||||
|
############################################
|
||||||
FROM release AS nightly
|
FROM release AS nightly
|
||||||
RUN npm run mark-as-nightly
|
RUN npm run mark-as-nightly
|
||||||
|
|
||||||
|
############################################
|
||||||
# Build an image for testing pr
|
# Build an image for testing pr
|
||||||
|
############################################
|
||||||
FROM louislam/uptime-kuma:base-debian AS pr-test
|
FROM louislam/uptime-kuma:base-debian AS pr-test
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
@ -54,8 +77,9 @@ VOLUME ["/app/data"]
|
|||||||
HEALTHCHECK --interval=60s --timeout=30s --start-period=180s --retries=5 CMD node extra/healthcheck.js
|
HEALTHCHECK --interval=60s --timeout=30s --start-period=180s --retries=5 CMD node extra/healthcheck.js
|
||||||
CMD ["npm", "run", "start-pr-test"]
|
CMD ["npm", "run", "start-pr-test"]
|
||||||
|
|
||||||
|
############################################
|
||||||
# Upload the artifact to Github
|
# Upload the artifact to Github
|
||||||
|
############################################
|
||||||
FROM louislam/uptime-kuma:base-debian AS upload-artifact
|
FROM louislam/uptime-kuma:base-debian AS upload-artifact
|
||||||
WORKDIR /
|
WORKDIR /
|
||||||
RUN apt update && \
|
RUN apt update && \
|
||||||
|
77
extra/healthcheck.go
Normal file
77
extra/healthcheck.go
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/tls"
|
||||||
|
"io/ioutil"
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"runtime"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
isFreeBSD := runtime.GOOS == "freebsd"
|
||||||
|
|
||||||
|
// process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
|
||||||
|
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{
|
||||||
|
InsecureSkipVerify: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
client := http.Client{
|
||||||
|
Timeout: 28 * time.Second,
|
||||||
|
}
|
||||||
|
|
||||||
|
sslKey := os.Getenv("UPTIME_KUMA_SSL_KEY")
|
||||||
|
if len(sslKey) == 0 {
|
||||||
|
sslKey = os.Getenv("SSL_KEY")
|
||||||
|
}
|
||||||
|
|
||||||
|
sslCert := os.Getenv("UPTIME_KUMA_SSL_CERT")
|
||||||
|
if len(sslCert) == 0 {
|
||||||
|
sslCert = os.Getenv("SSL_CERT")
|
||||||
|
}
|
||||||
|
|
||||||
|
hostname := os.Getenv("UPTIME_KUMA_HOST")
|
||||||
|
if len(hostname) == 0 && !isFreeBSD {
|
||||||
|
hostname = os.Getenv("HOST")
|
||||||
|
}
|
||||||
|
if len(hostname) == 0 {
|
||||||
|
hostname = "127.0.0.1"
|
||||||
|
}
|
||||||
|
|
||||||
|
port := os.Getenv("UPTIME_KUMA_PORT")
|
||||||
|
if len(port) == 0 {
|
||||||
|
port = os.Getenv("PORT")
|
||||||
|
}
|
||||||
|
if len(port) == 0 {
|
||||||
|
port = "3001"
|
||||||
|
}
|
||||||
|
|
||||||
|
protocol := ""
|
||||||
|
if len(sslKey) != 0 && len(sslCert) == 0 {
|
||||||
|
protocol = "https"
|
||||||
|
} else {
|
||||||
|
protocol = "http"
|
||||||
|
}
|
||||||
|
|
||||||
|
url := protocol + "://" + hostname + ":" + port
|
||||||
|
|
||||||
|
log.Println("Checking " + url)
|
||||||
|
resp, err := client.Get(url)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalln(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
_, err = ioutil.ReadAll(resp.Body)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalln(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Printf("Health Check OK [Res Code: %d]\n", resp.StatusCode)
|
||||||
|
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
|
* ⚠️ Deprecated: Changed to healthcheck.go, it will be deleted in the future.
|
||||||
* This script should be run after a period of time (180s), because the server may need some time to prepare.
|
* This script should be run after a period of time (180s), because the server may need some time to prepare.
|
||||||
*/
|
*/
|
||||||
const { FBSD } = require("../server/util-server");
|
const { FBSD } = require("../server/util-server");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user