mirror of
https://github.com/seriousm4x/UpSnap.git
synced 2026-03-31 06:24:11 -04:00
feat: UPSNAP_HTTP_LISTEN: check for custom addr in go
This commit is contained in:
@@ -14,13 +14,13 @@ RUN wget https://github.com/seriousm4x/UpSnap/releases/download/${VERSION}/UpSna
|
||||
setcap 'cap_net_raw=+ep' ./upsnap
|
||||
|
||||
FROM alpine:3
|
||||
ARG HTTP_LISTEN=127.0.0.1:8090
|
||||
ENV HTTP_LISTEN=${HTTP_LISTEN}
|
||||
ARG UPSNAP_HTTP_LISTEN=127.0.0.1:8090
|
||||
ENV UPSNAP_HTTP_LISTEN=${UPSNAP_HTTP_LISTEN}
|
||||
RUN apk update &&\
|
||||
apk add --no-cache tzdata ca-certificates nmap samba samba-common-tools openssh sshpass curl &&\
|
||||
rm -rf /var/cache/apk/*
|
||||
WORKDIR /app
|
||||
COPY --from=downloader /app/upsnap upsnap
|
||||
HEALTHCHECK --interval=10s \
|
||||
CMD curl -fs "http://${HTTP_LISTEN}/api/health" || exit 1
|
||||
ENTRYPOINT ["sh", "-c", "./upsnap serve --http $HTTP_LISTEN"]
|
||||
CMD curl -fs "http://${UPSNAP_HTTP_LISTEN}/api/health" || exit 1
|
||||
ENTRYPOINT ["sh", "-c", "./upsnap serve"]
|
||||
|
||||
@@ -17,13 +17,13 @@ RUN go build -o upsnap main.go &&\
|
||||
setcap 'cap_net_raw=+ep' ./upsnap
|
||||
|
||||
FROM alpine:3
|
||||
ARG HTTP_LISTEN=127.0.0.1:8090
|
||||
ENV HTTP_LISTEN=${HTTP_LISTEN}
|
||||
ARG UPSNAP_HTTP_LISTEN=127.0.0.1:8090
|
||||
ENV UPSNAP_HTTP_LISTEN=${UPSNAP_HTTP_LISTEN}
|
||||
RUN apk update &&\
|
||||
apk add --no-cache tzdata ca-certificates nmap samba samba-common-tools openssh sshpass curl &&\
|
||||
rm -rf /var/cache/apk/*
|
||||
WORKDIR /app
|
||||
COPY --from=go /app/upsnap upsnap
|
||||
HEALTHCHECK --interval=10s \
|
||||
CMD curl -fs "http://${HTTP_LISTEN}/api/health" || exit 1
|
||||
ENTRYPOINT ["sh", "-c", "./upsnap serve --http $HTTP_LISTEN"]
|
||||
CMD curl -fs "http://${UPSNAP_HTTP_LISTEN}/api/health" || exit 1
|
||||
ENTRYPOINT ["sh", "-c", "./upsnap serve"]
|
||||
|
||||
@@ -94,13 +94,13 @@ If you want to change the port from 8090 to something else, change the following
|
||||
|
||||
```yml
|
||||
environment:
|
||||
- HTTP_LISTEN=0.0.0.0:5000
|
||||
- UPSNAP_HTTP_LISTEN=0.0.0.0:5000
|
||||
```
|
||||
|
||||
### Install additional packages for shutdown cmd
|
||||
|
||||
```yml
|
||||
entrypoint: /bin/sh -c "apk update && apk add --no-cache <YOUR_PACKAGE> && rm -rf /var/cache/apk/* && ./upsnap serve --http $HTTP_LISTEN"
|
||||
entrypoint: /bin/sh -c "apk update && apk add --no-cache <YOUR_PACKAGE> && rm -rf /var/cache/apk/* && ./upsnap serve"
|
||||
```
|
||||
|
||||
You can search for your needed package [here](https://pkgs.alpinelinux.org/packages).
|
||||
|
||||
@@ -188,11 +188,26 @@ func StartPocketBase(distDirFS fs.FS) {
|
||||
return e.Next()
|
||||
})
|
||||
|
||||
// check for custom http listen address in env var, else use default
|
||||
httpListen := os.Getenv("UPSNAP_HTTP_LISTEN")
|
||||
if httpListen != "" {
|
||||
if err := app.Bootstrap(); err != nil {
|
||||
logger.Error.Fatalln(err)
|
||||
}
|
||||
if err := apis.Serve(app, apis.ServeConfig{
|
||||
HttpAddr: httpListen,
|
||||
ShowStartBanner: true,
|
||||
}); err != nil {
|
||||
logger.Error.Fatalln(err)
|
||||
}
|
||||
} else {
|
||||
if err := app.Start(); err != nil {
|
||||
logger.Error.Fatalln(err)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func importSettings(app *pocketbase.PocketBase) error {
|
||||
settingsPrivateRecords, err := app.FindAllRecords("settings_private")
|
||||
if err != nil {
|
||||
|
||||
@@ -11,8 +11,8 @@ services:
|
||||
# # the container (mkdir data) so that it has the right permissions.
|
||||
# user: 1000:1000
|
||||
# environment:
|
||||
# - HTTP_LISTEN=127.0.0.1:8090
|
||||
# - TZ=Europe/Berlin # Set container timezone for cron schedules
|
||||
# - UPSNAP_HTTP_LISTEN=127.0.0.1:8090
|
||||
# - UPSNAP_INTERVAL=*/10 * * * * * # Sets the interval in which the devices are pinged
|
||||
# - UPSNAP_SCAN_RANGE=192.168.1.0/24 # Scan range is used for device discovery on local network
|
||||
# - UPSNAP_WEBSITE_TITLE=Custom name # Custom website title
|
||||
@@ -26,4 +26,4 @@ services:
|
||||
# test: curl -fs "http://localhost:5000/api/health" || exit 1
|
||||
# interval: 10s
|
||||
# # or install custom packages for shutdown
|
||||
# entrypoint: /bin/sh -c "apk update && apk add --no-cache <YOUR_PACKAGE> && rm -rf /var/cache/apk/* && ./upsnap serve --http $HTTP_LISTEN"
|
||||
# entrypoint: /bin/sh -c "apk update && apk add --no-cache <YOUR_PACKAGE> && rm -rf /var/cache/apk/* && ./upsnap serve"
|
||||
|
||||
@@ -9,8 +9,8 @@ services:
|
||||
# # To use a non-root user, create the mountpoint first (mkdir data) so that it has the right permission.
|
||||
# user: 1000:1000
|
||||
# environment:
|
||||
# - HTTP_LISTEN=127.0.0.1:8090
|
||||
# - TZ=Europe/Berlin # Set container timezone for cron schedules
|
||||
# - UPSNAP_HTTP_LISTEN=127.0.0.1:8090
|
||||
# - UPSNAP_INTERVAL=*/10 * * * * * # Sets the interval in which the devices are pinged
|
||||
# - UPSNAP_SCAN_RANGE=192.168.1.0/24 # Scan range is used for device discovery on local network
|
||||
# - UPSNAP_SCAN_TIMEOUT=500ms # Scan timeout is nmap's --host-timeout value to wait for devices (https://nmap.org/book/man-performance.html)
|
||||
@@ -21,4 +21,4 @@ services:
|
||||
# - 192.18.0.1
|
||||
# - 192.18.0.2
|
||||
# # or install custom packages for shutdown
|
||||
# entrypoint: /bin/sh -c "apk update && apk add --no-cache <YOUR_PACKAGE> && rm -rf /var/cache/apk/* && ./upsnap serve --http $HTTP_LISTEN"
|
||||
# entrypoint: /bin/sh -c "apk update && apk add --no-cache <YOUR_PACKAGE> && rm -rf /var/cache/apk/* && ./upsnap serve"
|
||||
|
||||
Reference in New Issue
Block a user