Skip to content

Commit 6d21d38

Browse files
committed
update nginx to 1.13.6 and multi-stage build
1 parent a301a39 commit 6d21d38

File tree

7 files changed

+38
-33
lines changed

7 files changed

+38
-33
lines changed

Dockerfile

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,29 @@ MAINTAINER friends@niiknow.org
44

55
ENV LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 LANGUAGE=en_US.UTF-8 \
66
TERM=xterm container=docker DEBIAN_FRONTEND=noninteractive \
7-
NGINX_VERSION=1.13.4-1~xenial_amd64.deb
7+
NGINX_VERSION=1.13.6
88

9-
ADD ./build/nginx_${NGINX_VERSION} /tmp
9+
ENV NGINX_BUILD_DIR=/usr/src/nginx/nginx-${NGINX_VERSION} \
10+
NGINX_DEVEL_KIT_VERSION=0.3.0 NGINX_SET_MISC_MODULE_VERSION=0.31
1011

11-
# ADD ./build/nginx-dbg_${NGINX_VERSION} /tmp
12+
ADD ./build/src/ /tmp/
13+
14+
RUN \
15+
cd /tmp \
16+
&& bash ubuntu.sh
17+
18+
# build 2
19+
FROM hyperknot/baseimage16:1.0.2
20+
21+
MAINTAINER friends@niiknow.org
22+
23+
# files are nginx_***_adm64.deb or nginx-dbg_***_adm64.deb
24+
25+
ENV LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 LANGUAGE=en_US.UTF-8 \
26+
TERM=xterm container=docker DEBIAN_FRONTEND=noninteractive \
27+
NGINX_VERSION=1.13.6-1~xenial_amd64.deb
28+
29+
COPY --from=0 /usr/src/nginx/nginx_${NGINX_VERSION} /tmp
1230

1331
# start
1432
RUN \

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
# Pure Nginx Image Resize/Crop Microservice
2-
Image cropping with gravity, resize and compress on the fly with nginx image_filter module. A tiny docker container to build your own Cloudinary-like service.
1+
# nginx image proxy
2+
>High Performance and Low Resource Utilization Microservice
3+
4+
image cropping with gravity, resize and compress on the fly with nginx **image_filter** module. A tiny docker container to build your own Cloudinary-like service.
35

46
Nginx module - https://github.com/niiknow/docker-nginx-image-proxy/blob/master/build/src/ngx_http_image_filter_module.c
57

@@ -10,7 +12,8 @@ Features:
1012
- [x] convert/force output to another format, support formats: bmp, jpg, png, gif, webp, and tiff
1113
- [x] use custom ssl and saved config when you mount '/app' volume. nginx logs has also been redirect so you can backup, such as aws s3 sync. Just delete the default redirect to stdout/access.log and stderr/error.log files.
1214
- [x] support international characters in URL
13-
- [x] automatically follow redirect at origin
15+
- [x] automatically follow redirect at origin
16+
- [x] overridable nginx config - easily add secure link or additional nginx config
1417

1518
# What does this solve?
1619
You have a huge repository of images that need dynamic resize and cropping. Cloudinary can be expensive and redundant if you run your own CDN in front of this microservice.
@@ -23,7 +26,11 @@ Unlike other libraries, this does not try to do every image transformation and/o
2326
3. If you want thumbnail caching to s3, just write a lambda function and use this server to generate your thumbnail. Upload the result to s3 with the same function.
2427

2528
# build
29+
To achieve smaller/tiny microservice, this container utilize multi-stage build introduced in Docker 17.06; therefore, Docker 17.06+ is required to build.
30+
31+
```
2632
docker build -t nginx-image-proxy .
33+
```
2734

2835
# run
2936
docker run -d --restart=always -p 80:80 niiknow/nginx-image-proxy

build/Dockerfile

Lines changed: 0 additions & 20 deletions
This file was deleted.
-8.14 MB
Binary file not shown.

build/nginx_1.13.4-1~xenial_amd64.deb

-793 KB
Binary file not shown.

build/src/ubuntu.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
#!/bin/bash
22

3-
export NGINX_VERSION=1.13.4
4-
export NGINX_BUILD_DIR=/usr/src/nginx/nginx-${NGINX_VERSION}
5-
export NGINX_DEVEL_KIT_VERSION=0.3.0
6-
export NGINX_SET_MISC_MODULE_VERSION=0.31
73
cd /tmp
84

95
curl -sL "https://github.com/simpl/ngx_devel_kit/archive/v$NGINX_DEVEL_KIT_VERSION.tar.gz" -o dev-kit.tar.gz
@@ -33,6 +29,9 @@ mkdir -p /usr/src/nginx
3329
cd /usr/src/nginx
3430
apt-get source nginx=${NGINX_VERSION} -y
3531

32+
pwd
33+
ls -la
34+
3635
cd ${NGINX_BUILD_DIR}/src/http/modules/
3736
mv ngx_http_image_filter_module.c ngx_http_image_filter_module.bak
3837
mv /tmp/ngx_http_image_filter_module.c ./ngx_http_image_filter_module.c
@@ -45,3 +44,6 @@ apt-get build-dep nginx -y
4544
cd ${NGINX_BUILD_DIR}
4645
dpkg-buildpackage -uc -us -b
4746

47+
cd /usr/src/nginx
48+
pwd
49+
ls -la

docker-compose.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ services:
55
image: niiknow/nginx-image-proxy
66
restart: always
77
container_name: nginx-image-proxy
8-
environment:
9-
- SERVER_CONF=${SERVER_CONF}
108
ports:
119
- '80:80'
12-
- '443:443'
10+
- '443:443'

0 commit comments

Comments
 (0)