Skip to content

Commit 3570827

Browse files
authored
Merge pull request #1 from mendhak/master
Sync to upstream v16
2 parents 58b5b88 + 311c55e commit 3570827

4 files changed

Lines changed: 68 additions & 16 deletions

File tree

CHANGELOG.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
## Version `16` - 2020-12-22
3+
4+
* Dockerfile optimisation, slightly smaller image size
5+
* This changelog added to the repo
6+
7+
## Version `15` - 2020-12-15
8+
9+
* The image now runs as a non-root user by default.
10+
11+
## Version `14` - 2020-11-26
12+
13+
* Optionally allow running as a non root user.
14+
15+
```
16+
docker run --user node -e HTTP_PORT=8080 -e HTTPS_PORT=8443 -p 8080:8080 -p 8443:8443 --rm mendhak/http-https-echo:issue-14-non-root
17+
#or
18+
docker run --user node --sysctl net.ipv4.ip_unprivileged_port_start=0 -p 8080:80 -p 8443:443 --rm mendhak/http-https-echo:issue-14-non-root
19+
```
20+
21+
## Version `latest` and others
22+
23+
_Note: The `latest` tag is no longer being built, I've removed it from the automated builds. Please don't use the `latest` tag any longer._
24+
25+
* JWT header
26+
* Choose your own ports
27+
* Choose your own certs
28+
* Ignore a specific path
29+
* JSON payloads
30+
* Single line log output
31+

Dockerfile

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
1-
FROM node:14-alpine
1+
FROM node:14-alpine AS build
22

33
WORKDIR /app
44
COPY . /app
5-
ENV HTTP_PORT=8080 HTTPS_PORT=8443
6-
7-
RUN npm install --production
8-
RUN apk --no-cache add openssl && sh generate-cert.sh && rm -rf /var/cache/apk/*
95

10-
RUN chmod -R 775 /app
11-
RUN chown -R node:node /app
6+
RUN set -ex \
7+
# Build JS-Application
8+
&& npm install --production \
9+
# Generate SSL-certificate (for HTTPS)
10+
&& apk --no-cache add openssl \
11+
&& sh generate-cert.sh \
12+
&& apk del openssl \
13+
&& rm -rf /var/cache/apk/* \
14+
# Delete unnecessary files
15+
&& rm package* generate-cert.sh \
16+
# Correct User's file access
17+
&& chown -R node:node /app
1218

19+
FROM node:14-alpine AS final
20+
WORKDIR /app
21+
COPY --from=build /app /app
22+
ENV HTTP_PORT=8080 HTTPS_PORT=8443
23+
EXPOSE $HTTP_PORT
24+
EXPOSE $HTTPS_PORT
1325
USER 1000
14-
1526
CMD ["node", "./index.js"]

README.md

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Please do not use the `:latest` tag as it will break without warning, use a spec
1818

1919
Run with Docker
2020

21-
docker run -p 8080:8080 -p 8443:8443 --rm -t mendhak/http-https-echo:15
21+
docker run -p 8080:8080 -p 8443:8443 --rm -t mendhak/http-https-echo:16
2222

2323
Or run with Docker Compose
2424

@@ -35,13 +35,13 @@ You can choose a different internal port instead of 8080 and 8443 with the `HTTP
3535

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

38-
docker run -e HTTP_PORT=8888 -e HTTPS_PORT=9999 -p 8080:8888 -p 8443:9999 --rm -t mendhak/http-https-echo:15
38+
docker run -e HTTP_PORT=8888 -e HTTPS_PORT=9999 -p 8080:8888 -p 8443:9999 --rm -t mendhak/http-https-echo:16
3939

4040

4141
With docker compose, this would be:
4242

4343
my-http-listener:
44-
image: mendhak/http-https-echo:15
44+
image: mendhak/http-https-echo:16
4545
environment:
4646
- HTTP_PORT=8888
4747
- HTTPS_PORT=9999
@@ -55,7 +55,7 @@ With docker compose, this would be:
5555
Use volume mounting to substitute the certificate and private key with your own. This example uses the snakeoil cert.
5656

5757
my-http-listener:
58-
image: mendhak/http-https-echo:15
58+
image: mendhak/http-https-echo:16
5959
ports:
6060
- "8080:8080"
6161
- "8443:8443"
@@ -69,7 +69,7 @@ Use volume mounting to substitute the certificate and private key with your own.
6969

7070
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.
7171

72-
docker run -e JWT_HEADER=Authentication -p 8080:8080 -p 8443:8443 --rm -it mendhak/http-https-echo:15
72+
docker run -e JWT_HEADER=Authentication -p 8080:8080 -p 8443:8443 --rm -it mendhak/http-https-echo:16
7373

7474

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

86-
docker run -e LOG_IGNORE_PATH=/ping -p 8080:8080 -p 8443:8443 --rm -t mendhak/http-https-echo:15
86+
docker run -e LOG_IGNORE_PATH=/ping -p 8080:8080 -p 8443:8443 --rm -t mendhak/http-https-echo:16
8787

8888

8989
With docker compose, this would be:
9090

9191
my-http-listener:
92-
image: mendhak/http-https-echo:15
92+
image: mendhak/http-https-echo:16
9393
environment:
9494
- LOG_IGNORE_PATH=/ping
9595
ports:
@@ -134,3 +134,13 @@ Will contain a `json` property in the response/output.
134134
Run some tests to make sure features are working as expected.
135135

136136
./tests.sh
137+
138+
To create a new image on Docker Hub, I need to create a tag and push it.
139+
140+
git tag -s 16
141+
git push --tags
142+
143+
144+
## Changelog
145+
146+
See the [changelog](CHANGELOG.md)

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:15
2+
image: mendhak/http-https-echo:16
33
environment:
44
- HTTP_PORT=8888
55
- HTTPS_PORT=9999

0 commit comments

Comments
 (0)