File tree Expand file tree Collapse file tree 7 files changed +40
-19
lines changed
Expand file tree Collapse file tree 7 files changed +40
-19
lines changed Original file line number Diff line number Diff line change 1919 run : docker build . -t build
2020 - name : Testing image
2121 shell : bash
22+ working-directory : tests
2223 run : |
23- docker run -d -p 8080:80 build
24- ./tests/test.sh
24+ docker build . -t test
25+ docker run -d -p 8080:80 test
26+ ./test.sh
2527 docker stop $(docker ps -aq)
2628 - name : Push the Docker image
2729 if : github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')
Original file line number Diff line number Diff line change 11# ngxjs
22This nginx container with support modules njs and Brotli, also use BoringSSL instead OpenSSL.
33
4- ## Testing
5-
6- ``` bash
7- $ docker run -p 8080:80 ngxjs:v0.0.2
8- $ ./tests/test.sh
9-
10- Test passed!
11- ```
12-
134## Usage
145
156In your Dockerfile just use in ` FROM ` directive and ` COPY ` your assets to ` /usr/share/nginx/html ` folder.
Original file line number Diff line number Diff line change @@ -25,15 +25,17 @@ http {
2525 application/vnd.ms-fontobject application/x-font-opentype application/x-font-truetype
2626 application/x-font-ttf application/x-javascript application/xhtml+xml application/xml
2727 font/eot font/opentype font/otf font/truetype image/svg+xml image/vnd.microsoft.icon
28- image/x-icon image/x-win-bitmap text/css text/javascript text/plain text/xml;
28+ image/x-icon image/x-win-bitmap text/css text/javascript text/plain text/xml
29+ image/bmp image/png image/gif image/jpeg image/jpg;
2930
3031 brotli on;
3132 brotli_comp_level 6;
3233 brotli_types application/atom+xml application/javascript application/json application/rss+xml
3334 application/vnd.ms-fontobject application/x-font-opentype application/x-font-truetype
3435 application/x-font-ttf application/x-javascript application/xhtml+xml application/xml
3536 font/eot font/opentype font/otf font/truetype image/svg+xml image/vnd.microsoft.icon
36- image/x-icon image/x-win-bitmap text/css text/javascript text/plain text/xml;
37+ image/x-icon image/x-win-bitmap text/css text/javascript text/plain text/xml
38+ image/bmp image/png image/gif image/jpeg image/jpg;
3739
3840 server {
3941 listen 80 ;
Original file line number Diff line number Diff line change 1+ FROM build
2+
3+ COPY assets /usr/share/nginx/html
4+
5+ EXPOSE 80
6+
7+ ENTRYPOINT [ "nginx" , "-g" , "daemon off;" ]
Original file line number Diff line number Diff line change 1+ assets/image.jpg
Original file line number Diff line number Diff line change @@ -6,33 +6,51 @@ DIR=$(dirname "$0")
66
77basic_case () {
88 curl http://$host :8080 > $DIR /basic_case.html
9- check " basic_case"
9+ check " basic_case.html "
1010}
1111
1212gzip_case () {
1313 curl -sH ' Accept-encoding: gzip' http://$host :8080 | gunzip - > $DIR /gzip.html
14- check " gzip"
14+ check " gzip.html "
1515}
1616
1717brotli_case () {
1818 curl -sH ' Accept-encoding: br' http://$host :8080 | brotli --decompress - > $DIR /brotli.html
19- check " brotli"
19+ check " brotli.html"
20+ }
21+
22+ basic_image_case () {
23+ curl http://$host :8080/image.jpg > $DIR /image.jpg
24+ check " image.jpg"
25+ }
26+
27+ gzip_image_case () {
28+ curl -sH ' Accept-encoding: gzip' http://$host :8080/image.jpg | gunzip - > $DIR /image.jpg
29+ check " image.jpg"
30+ }
31+
32+ brotli_image_case () {
33+ curl -sH ' Accept-encoding: br' http://$host :8080/image.jpg | brotli --decompress - > $DIR /image.jpg
34+ check " image.jpg"
2035}
2136
2237check () {
23- if [ -z ` diff $DIR /$1 .html $DIR /expected_$1 .html ` ]; then
24- rm $DIR /$1 .html
38+ if [ -z ` diff $DIR /$1 $DIR /expected_$1 ` ]; then
39+ rm $DIR /$1
2540 return
2641 fi
2742
28- rm $DIR /$1 .html
43+ rm $DIR /$1
2944 echo -e " \n\e[31mTest" $1 " failed!\e[0m\n"
3045 exit 1
3146}
3247
3348basic_case
3449gzip_case
3550brotli_case
51+ basic_image_case
52+ gzip_image_case
53+ brotli_image_case
3654
3755echo -e " \n\e[32mTests passed!\e[0m\n"
3856exit 0
You can’t perform that action at this time.
0 commit comments