Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for http_proxy and no_proxy #166

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ FROM openjdk:8-jre-alpine

WORKDIR /validator

COPY docker-entrypoint.sh .
COPY target/lib/jetty-runner.jar /validator/jetty-runner.jar
COPY target/*.war /validator/server.war
COPY src/main/swagger/swagger.yaml /validator/
Expand All @@ -11,5 +12,4 @@ ENV REJECT_REDIRECT "true"
ENV REJECT_LOCAL "true"
EXPOSE 8080

CMD java -jar -DswaggerUrl=swagger.yaml -DrejectLocal=${REJECT_LOCAL} -DrejectRedirect=${REJECT_REDIRECT} /validator/jetty-runner.jar /validator/server.war

ENTRYPOINT ["./docker-entrypoint.sh"]
17 changes: 17 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

#Automaticly import system proxy settings
if [ -n "$http_proxy" ] ; then
echo $http_proxy | grep "@"
if [ $? -eq 0 ]; then # If variable has username and password, its parse method different
PROXY_HOST=$(echo $http_proxy | sed 's/http:\/\/.*@\(.*\):.*/\1/')
PROXY_PORT=$(echo $http_proxy | sed 's/http:\/\/.*@.*:\(.*\)/\1/' | tr -d "/")
USERNAME=$(echo $http_proxy | sed 's/http:\/\/\(.*\)@.*/\1/'|awk -F: '{print $1}')
PASSWORD=$(echo $http_proxy | sed 's/http:\/\/\(.*\)@.*/\1/'|awk -F: '{print $2}')
else # If it doesn't have username and password, its parse method this
PROXY_HOST=$(echo $http_proxy | sed 's/http:\/\/\(.*\):.*/\1/')
PROXY_PORT=$(echo $http_proxy | sed 's/http:\/\/.*:\(.*\)/\1/' | tr -d "/")
fi
fi

java -Dhttp.proxyHost=$PROXY_HOST -Dhttp.proxyPort=$PROXY_PORT -Dhttp.proxyUser=$USERNAME -Dhttp.proxyPassword=$PASSWORD -Dhttp.nonProxyHosts=$no_proxy -jar -DswaggerUrl=swagger.yaml -DrejectLocal=$REJECT_LOCAL -DrejectRedirect=$REJECT_REDIRECT /validator/jetty-runner.jar /validator/server.war