From 0ac97e30f503b909dea1ae0bba340b37b3eb82ad Mon Sep 17 00:00:00 2001 From: peterzen Date: Wed, 29 Jan 2025 05:55:15 +0100 Subject: [PATCH] Set --webaddr to obtained container IP (#3114) --- .dockerignore | 2 ++ client/Dockerfile | 5 +++-- client/Dockerfile.release | 5 +++-- client/entrypoint.sh | 11 +++++++++++ 4 files changed, 19 insertions(+), 4 deletions(-) create mode 100755 client/entrypoint.sh diff --git a/.dockerignore b/.dockerignore index 0e49dd21c3..48a87b69cc 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1,3 @@ client/webserver/site/node_modules/ +spec/ +docs/ diff --git a/client/Dockerfile b/client/Dockerfile index 7b367106d2..efc0fc65d4 100644 --- a/client/Dockerfile +++ b/client/Dockerfile @@ -44,10 +44,11 @@ RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build FROM debian:buster-slim RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y ca-certificates WORKDIR /dex -ENV HOME /dex +ENV HOME=/dex RUN mkdir -p /dex/.dexc && chown 1000 /dex/.dexc USER 1000 COPY --from=gobuilder /root/dex/client/cmd/bisonw/bisonw ./ COPY --from=gobuilder /root/dex/client/cmd/bwctl/bwctl ./ +COPY ./client/entrypoint.sh ./ EXPOSE 5758 -CMD [ "./bisonw", "--webaddr=0.0.0.0:5758" ] +ENTRYPOINT [ "./entrypoint.sh" ] diff --git a/client/Dockerfile.release b/client/Dockerfile.release index 2de9082660..c2e2e24834 100644 --- a/client/Dockerfile.release +++ b/client/Dockerfile.release @@ -32,10 +32,11 @@ RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build FROM debian:buster-slim RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y ca-certificates WORKDIR /dex -ENV HOME /dex +ENV HOME=/dex RUN mkdir -p /dex/.dexc && chown 1000 /dex/.dexc USER 1000 COPY --from=gobuilder /root/dex/client/cmd/bisonw/bisonw ./ COPY --from=gobuilder /root/dex/client/cmd/bwctl/bwctl ./ +COPY ./client/entrypoint.sh ./ EXPOSE 5758 -CMD [ "./bisonw", "--webaddr=0.0.0.0:5758" ] +ENTRYPOINT [ "./entrypoint.sh" ] diff --git a/client/entrypoint.sh b/client/entrypoint.sh new file mode 100755 index 0000000000..0b63e6b49f --- /dev/null +++ b/client/entrypoint.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +# Get the IP address of the primary network interface +IP_ADDRESS=$(hostname -I | awk '{print $1}') + +CMD="./bisonw" +if [ "$IP_ADDRESS" != "" ]; then + CMD="$CMD --webaddr $IP_ADDRESS:5758" +fi + +exec $CMD