diff --git a/Dockerfile b/Dockerfile index 6788b1ef..a1a52e16 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,11 +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} 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://localhost:8090/api/health" || exit 1 -ENTRYPOINT ["./upsnap", "serve", "--http=0.0.0.0:8090"] + CMD curl -fs "http://${HTTP_LISTEN}/api/health" || exit 1 +ENTRYPOINT ["sh", "-c", "./upsnap serve --http $HTTP_LISTEN"] diff --git a/Dockerfile.dev b/Dockerfile.dev index e71e6121..cef4ec8f 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -17,11 +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} 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://localhost:8090/api/health" || exit 1 -ENTRYPOINT ["./upsnap", "serve", "--http=0.0.0.0:8090"] + CMD curl -fs "http://${HTTP_LISTEN}/api/health" || exit 1 +ENTRYPOINT ["sh", "-c", "./upsnap serve --http $HTTP_LISTEN"] diff --git a/README.md b/README.md index 02bcbfac..59eb7936 100644 --- a/README.md +++ b/README.md @@ -93,15 +93,14 @@ Then add `user: 1000:1000` to the docker-compose file (or whatever your $UID:$GI If you want to change the port from 8090 to something else, change the following (5000 in this case): ```yml -entrypoint: /bin/sh -c "./upsnap serve --http 0.0.0.0:5000" -healthcheck: - test: curl -fs "http://localhost:5000/api/health" || exit 1 +environment: + - HTTP_LISTEN=0.0.0.0:5000 ``` ### Install additional packages for shutdown cmd ```yml -entrypoint: /bin/sh -c "apk update && apk add --no-cache && rm -rf /var/cache/apk/* && ./upsnap serve --http 0.0.0.0:8090" +entrypoint: /bin/sh -c "apk update && apk add --no-cache && rm -rf /var/cache/apk/* && ./upsnap serve --http $HTTP_LISTEN" ``` You can search for your needed package [here](https://pkgs.alpinelinux.org/packages). diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index c2258244..b8a3039d 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -11,6 +11,7 @@ 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_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 @@ -25,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 && rm -rf /var/cache/apk/* && ./upsnap serve --http 0.0.0.0:8090" + # entrypoint: /bin/sh -c "apk update && apk add --no-cache && rm -rf /var/cache/apk/* && ./upsnap serve --http $HTTP_LISTEN" diff --git a/docker-compose.yml b/docker-compose.yml index 1506414b..565ceeda 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,6 +9,7 @@ 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_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 @@ -19,10 +20,5 @@ services: # dns: # - 192.18.0.1 # - 192.18.0.2 - # # you can change the listen ip:port inside the container like this: - # entrypoint: /bin/sh -c "./upsnap serve --http 0.0.0.0:5000" - # healthcheck: - # 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 && rm -rf /var/cache/apk/* && ./upsnap serve --http 0.0.0.0:8090" + # entrypoint: /bin/sh -c "apk update && apk add --no-cache && rm -rf /var/cache/apk/* && ./upsnap serve --http $HTTP_LISTEN"