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
|
setcap 'cap_net_raw=+ep' ./upsnap
|
||||||
|
|
||||||
FROM alpine:3
|
FROM alpine:3
|
||||||
ARG HTTP_LISTEN=127.0.0.1:8090
|
ARG UPSNAP_HTTP_LISTEN=127.0.0.1:8090
|
||||||
ENV HTTP_LISTEN=${HTTP_LISTEN}
|
ENV UPSNAP_HTTP_LISTEN=${UPSNAP_HTTP_LISTEN}
|
||||||
RUN apk update &&\
|
RUN apk update &&\
|
||||||
apk add --no-cache tzdata ca-certificates nmap samba samba-common-tools openssh sshpass curl &&\
|
apk add --no-cache tzdata ca-certificates nmap samba samba-common-tools openssh sshpass curl &&\
|
||||||
rm -rf /var/cache/apk/*
|
rm -rf /var/cache/apk/*
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=downloader /app/upsnap upsnap
|
COPY --from=downloader /app/upsnap upsnap
|
||||||
HEALTHCHECK --interval=10s \
|
HEALTHCHECK --interval=10s \
|
||||||
CMD curl -fs "http://${HTTP_LISTEN}/api/health" || exit 1
|
CMD curl -fs "http://${UPSNAP_HTTP_LISTEN}/api/health" || exit 1
|
||||||
ENTRYPOINT ["sh", "-c", "./upsnap serve --http $HTTP_LISTEN"]
|
ENTRYPOINT ["sh", "-c", "./upsnap serve"]
|
||||||
|
|||||||
@@ -17,13 +17,13 @@ RUN go build -o upsnap main.go &&\
|
|||||||
setcap 'cap_net_raw=+ep' ./upsnap
|
setcap 'cap_net_raw=+ep' ./upsnap
|
||||||
|
|
||||||
FROM alpine:3
|
FROM alpine:3
|
||||||
ARG HTTP_LISTEN=127.0.0.1:8090
|
ARG UPSNAP_HTTP_LISTEN=127.0.0.1:8090
|
||||||
ENV HTTP_LISTEN=${HTTP_LISTEN}
|
ENV UPSNAP_HTTP_LISTEN=${UPSNAP_HTTP_LISTEN}
|
||||||
RUN apk update &&\
|
RUN apk update &&\
|
||||||
apk add --no-cache tzdata ca-certificates nmap samba samba-common-tools openssh sshpass curl &&\
|
apk add --no-cache tzdata ca-certificates nmap samba samba-common-tools openssh sshpass curl &&\
|
||||||
rm -rf /var/cache/apk/*
|
rm -rf /var/cache/apk/*
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=go /app/upsnap upsnap
|
COPY --from=go /app/upsnap upsnap
|
||||||
HEALTHCHECK --interval=10s \
|
HEALTHCHECK --interval=10s \
|
||||||
CMD curl -fs "http://${HTTP_LISTEN}/api/health" || exit 1
|
CMD curl -fs "http://${UPSNAP_HTTP_LISTEN}/api/health" || exit 1
|
||||||
ENTRYPOINT ["sh", "-c", "./upsnap serve --http $HTTP_LISTEN"]
|
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
|
```yml
|
||||||
environment:
|
environment:
|
||||||
- HTTP_LISTEN=0.0.0.0:5000
|
- UPSNAP_HTTP_LISTEN=0.0.0.0:5000
|
||||||
```
|
```
|
||||||
|
|
||||||
### Install additional packages for shutdown cmd
|
### Install additional packages for shutdown cmd
|
||||||
|
|
||||||
```yml
|
```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).
|
You can search for your needed package [here](https://pkgs.alpinelinux.org/packages).
|
||||||
|
|||||||
@@ -188,9 +188,24 @@ func StartPocketBase(distDirFS fs.FS) {
|
|||||||
return e.Next()
|
return e.Next()
|
||||||
})
|
})
|
||||||
|
|
||||||
if err := app.Start(); err != nil {
|
// check for custom http listen address in env var, else use default
|
||||||
logger.Error.Fatalln(err)
|
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 {
|
func importSettings(app *pocketbase.PocketBase) error {
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ services:
|
|||||||
# # the container (mkdir data) so that it has the right permissions.
|
# # the container (mkdir data) so that it has the right permissions.
|
||||||
# user: 1000:1000
|
# user: 1000:1000
|
||||||
# environment:
|
# environment:
|
||||||
# - HTTP_LISTEN=127.0.0.1:8090
|
|
||||||
# - TZ=Europe/Berlin # Set container timezone for cron schedules
|
# - 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_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_RANGE=192.168.1.0/24 # Scan range is used for device discovery on local network
|
||||||
# - UPSNAP_WEBSITE_TITLE=Custom name # Custom website title
|
# - UPSNAP_WEBSITE_TITLE=Custom name # Custom website title
|
||||||
@@ -26,4 +26,4 @@ services:
|
|||||||
# test: curl -fs "http://localhost:5000/api/health" || exit 1
|
# test: curl -fs "http://localhost:5000/api/health" || exit 1
|
||||||
# interval: 10s
|
# interval: 10s
|
||||||
# # or install custom packages for shutdown
|
# # 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.
|
# # To use a non-root user, create the mountpoint first (mkdir data) so that it has the right permission.
|
||||||
# user: 1000:1000
|
# user: 1000:1000
|
||||||
# environment:
|
# environment:
|
||||||
# - HTTP_LISTEN=127.0.0.1:8090
|
|
||||||
# - TZ=Europe/Berlin # Set container timezone for cron schedules
|
# - 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_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_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)
|
# - 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.1
|
||||||
# - 192.18.0.2
|
# - 192.18.0.2
|
||||||
# # or install custom packages for shutdown
|
# # 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