Skip to content

Commit ec9937f

Browse files
committed
Use specific version and cleanup, and README clarification
1 parent 37027d7 commit ec9937f

4 files changed

Lines changed: 13 additions & 35 deletions

File tree

Dockerfile

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
1-
# BUILD
2-
# docker build \
3-
# --force-rm=true \
4-
# -f Dockerfile \
5-
# -t docker-http-https-echo .
6-
7-
# RUN
8-
# docker run --rm -it \
9-
# -p 8080:8080 -p 8443:8443 \
10-
# docker-http-https-echo
11-
121
FROM node:14-alpine
132

143
WORKDIR /app

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ You can use your own certificates, choose your ports, decode JWT headers and fil
1111

1212
This image is executed as non root by default and is fully compliant with Kubernetes or Openshift deployment.
1313

14+
Please do not use the `:latest` tag as it will break without warning, use a specific version instead.
15+
1416
## Basic Usage
1517

1618
Run with Docker
1719

18-
docker run -p 8080:8080 -p 8443:8443 --rm -t mendhak/http-https-echo
20+
docker run -p 8080:8080 -p 8443:8443 --rm -t mendhak/http-https-echo:15
1921

2022
Or run with Docker Compose
2123

@@ -28,17 +30,17 @@ Then, issue a request via your browser or curl, and watch the response, as well
2830

2931
## Choose your ports
3032

31-
You can choose a different internal port instead of 80 and 443 with the `HTTP_PORT` and `HTTPS_PORT` environment variables.
33+
You can choose a different internal port instead of 8080 and 8443 with the `HTTP_PORT` and `HTTPS_PORT` environment variables.
3234

3335
In this example I'm setting http to listen on 8888, and https to listen on 9999.
3436

35-
docker run -e HTTP_PORT=8888 -e HTTPS_PORT=9999 -p 8080:8888 -p 8443:9999 --rm -t mendhak/http-https-echo
37+
docker run -e HTTP_PORT=8888 -e HTTPS_PORT=9999 -p 8080:8888 -p 8443:9999 --rm -t mendhak/http-https-echo:15
3638

3739

3840
With docker compose, this would be:
3941

4042
my-http-listener:
41-
image: mendhak/http-https-echo
43+
image: mendhak/http-https-echo:15
4244
environment:
4345
- HTTP_PORT=8888
4446
- HTTPS_PORT=9999
@@ -52,7 +54,7 @@ With docker compose, this would be:
5254
Use volume mounting to substitute the certificate and private key with your own. This example uses the snakeoil cert.
5355

5456
my-http-listener:
55-
image: mendhak/http-https-echo
57+
image: mendhak/http-https-echo:15
5658
ports:
5759
- "8080:8080"
5860
- "8443:8443"
@@ -66,7 +68,7 @@ Use volume mounting to substitute the certificate and private key with your own.
6668

6769
If you specify the header that contains the JWT, the echo output will contain the decoded JWT. Use the `JWT_HEADER` environment variable for this.
6870

69-
docker run -e JWT_HEADER=Authentication -p 8080:8080 -p 8443:8443 --rm -it mendhak/http-https-echo
71+
docker run -e JWT_HEADER=Authentication -p 8080:8080 -p 8443:8443 --rm -it mendhak/http-https-echo:15
7072

7173

7274
Now make your request with `Authentication: eyJ...` header (it should also work with the `Authentication: Bearer eyJ...` schema too):
@@ -80,13 +82,13 @@ And in the output you should see a `jwt` section.
8082
Set the environment variable `LOG_IGNORE_PATH` to a path you would like to exclude from verbose logging to stdout.
8183
This can help reduce noise from healthchecks in orchestration/infrastructure like Swarm, Kubernetes, ALBs, etc.
8284

83-
docker run -e LOG_IGNORE_PATH=/ping -p 8080:80 -p 8443:443 --rm -t mendhak/http-https-echo
85+
docker run -e LOG_IGNORE_PATH=/ping -p 8080:8080 -p 8443:8443 --rm -t mendhak/http-https-echo:15
8486

8587

8688
With docker compose, this would be:
8789

8890
my-http-listener:
89-
image: mendhak/http-https-echo
91+
image: mendhak/http-https-echo:15
9092
environment:
9193
- LOG_IGNORE_PATH=/ping
9294
ports:

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
my-http-listener:
2-
image: mendhak/http-https-echo
2+
image: mendhak/http-https-echo:15
33
environment:
44
- HTTP_PORT=8888
55
- HTTPS_PORT=9999

tests.sh

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ fi
172172
message " Stop containers "
173173
docker stop http-echo-tests
174174

175-
message " Check that container can run as a NON ROOT USER "
176-
docker run -d --name http-echo-tests --user node -e HTTP_PORT=8888 -e HTTPS_PORT=9999 -p 8080:8888 -p 8443:9999 --rm mendhak/http-https-echo
175+
message " Check that container is running as a NON ROOT USER by default"
176+
docker run -d --name http-echo-tests --rm mendhak/http-https-echo
177177

178178
WHOAMI=$(docker exec http-echo-tests whoami)
179179

@@ -185,19 +185,6 @@ else
185185
exit 1
186186
fi
187187

188-
message " Make http(s) request, and test the path, method and header. "
189-
REQUEST=$(curl -s -k -X PUT -H "Arbitrary:Header" -d aaa=bbb https://localhost:8443/hello-world)
190-
if [ $(echo $REQUEST | jq -r '.path') == '/hello-world' ] && \
191-
[ $(echo $REQUEST | jq -r '.method') == 'PUT' ] && \
192-
[ $(echo $REQUEST | jq -r '.headers.arbitrary') == 'Header' ]
193-
then
194-
passed "HTTPS request passed."
195-
else
196-
failed "HTTPS request failed."
197-
echo $REQUEST | jq
198-
exit 1
199-
fi
200-
201188
message " Stop containers "
202189
docker stop http-echo-tests
203190

0 commit comments

Comments
 (0)