Skip to content

Commit

Permalink
Add password protection support to docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
rb3ckers committed Jun 11, 2019
1 parent 3be9bf6 commit 2b41ea8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM debian:stretch

ADD ./init.sh /init
RUN chmod +x /init && apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*
ADD ./init.sh /init.sh
RUN chmod +x /init.sh && apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*

ADD build/trafficmirror /trafficmirror

CMD ["/init"]
CMD ["/init.sh"]

EXPOSE 8080
24 changes: 19 additions & 5 deletions init.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
#!/bin/sh

LISTEN_PORT=${LISTEN_PORT:-7077}
MAIN=${MAIN:-localhost:8888}
EXTRA_PARAMS=$1
# Takes these environment variables:
#
# LISTEN_PORT: port to listen on (defaults to 7077)
# MAIN: reverse proxy to this address (defaults to localhost:8888)
# USERNAME & PASSWORD: if USERNAME is set protect targets endpoint with basic auth (default to empty)

echo /trafficmirror /trafficmirror -listen ":${LISTEN_PORT}" -main=${MAIN} $EXTRA_PARAMS
/trafficmirror -listen ":${LISTEN_PORT}" -main=${MAIN} $EXTRA_PARAMS
listen_port=${LISTEN_PORT:-7077}
main=${MAIN:-localhost:8888}
extra_params=$1

if [ ! -z "${USERNAME}" ]
then
printf "${USERNAME}:${PASSWORD}" > /password.file
extra_params="${extra_params} -password /password.file"
fi

cmd="/trafficmirror -listen ":${listen_port}" -main=${main} $extra_params"

echo "$cmd"
eval "$cmd"

0 comments on commit 2b41ea8

Please sign in to comment.