Skip to content

Commit 8cd3593

Browse files
committed
Modernize docker related content
Use more common way of writting Dockerfile
1 parent 6d16fdb commit 8cd3593

File tree

4 files changed

+62
-40
lines changed

4 files changed

+62
-40
lines changed

docker-compose.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
version: '3'
22

3+
volumes:
4+
redirectionio-agent-data: {}
5+
36
services:
47
nginx:
58
build: services/nginx
@@ -15,3 +18,5 @@ services:
1518
- ./app:/var/www
1619
redirectionio-agent:
1720
build: services/redirectionio-agent
21+
volumes:
22+
- redirectionio-agent-data:/var/lib/redirectionio

services/nginx-compiled/Dockerfile

Lines changed: 40 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,69 @@
11
FROM nginx:1.19
22

3+
# install build tools
34
RUN apt update \
4-
&& apt install -y autoconf nginx build-essential gawk wget unzip \
5-
libssl-dev libpcre3-dev libzip-dev libxml2-dev libxslt-dev libgd-dev libgeoip-dev libperl-dev \
6-
gawk
5+
&& apt install -y \
6+
autoconf \
7+
build-essential \
8+
gawk \
9+
libgd-dev \
10+
libgeoip-dev \
11+
libpcre3-dev \
12+
libperl-dev \
13+
libssl-dev \
14+
libxml2-dev \
15+
libxslt-dev \
16+
libzip-dev \
17+
nginx \
18+
procps \
19+
unzip \
20+
wget \
21+
gawk \
22+
&& apt-get clean \
23+
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
724

825
# get nginx redirection.io module sources
926
WORKDIR /tmp
10-
11-
RUN wget -O libnginx-mod-redirectionio-master.zip https://github.com/redirectionio/libnginx-mod-redirectionio/archive/master.zip
12-
RUN unzip libnginx-mod-redirectionio-master.zip
27+
RUN wget -O libnginx-mod-redirectionio-master.zip https://github.com/redirectionio/libnginx-mod-redirectionio/archive/master.zip \
28+
&& unzip libnginx-mod-redirectionio-master.zip
1329

1430
# get nginx sources
1531
WORKDIR /root
16-
17-
RUN NGINX_VERSION=`nginx -v 2>&1 | gawk 'match($0,/nginx version: nginx\/([0-9\.]+?)/,a) {print a[1]}'` && \
18-
echo $NGINX_VERSION && \
19-
wget http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz && \
20-
tar -xzvf nginx-$NGINX_VERSION.tar.gz && \
21-
mv /root/nginx-$NGINX_VERSION /root/nginx && \
22-
rm nginx-$NGINX_VERSION.tar.gz
32+
RUN NGINX_VERSION=`nginx -v 2>&1 | gawk 'match($0,/nginx version: nginx\/([0-9\.]+?)/,a) {print a[1]}'` \
33+
&& echo $NGINX_VERSION \
34+
&& wget http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz \
35+
&& tar -xzvf nginx-$NGINX_VERSION.tar.gz \
36+
&& mv /root/nginx-$NGINX_VERSION /root/nginx \
37+
&& rm nginx-$NGINX_VERSION.tar.gz
2338

2439
# install Rust
2540
ENV RUSTUP_HOME=/opt/rust
2641
ENV CARGO_HOME=/opt/rust
27-
2842
RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain 1.59.0 -y --no-modify-path
2943
ENV PATH=/opt/rust/bin:$PATH
3044
RUN mkdir -p /opt/rust/registry
3145

3246
# get libredirectionio sources
3347
WORKDIR /tmp
34-
35-
RUN wget -O libredirectionio-master.zip https://github.com/redirectionio/libredirectionio/archive/master.zip
36-
RUN unzip libredirectionio-master.zip
48+
RUN wget -O libredirectionio-master.zip https://github.com/redirectionio/libredirectionio/archive/master.zip \
49+
&& unzip libredirectionio-master.zip
3750

3851
# build libredirectionio
3952
WORKDIR /tmp/libredirectionio-master
40-
RUN autoreconf -i && \
41-
./configure && \
42-
make clean && \
43-
make && \
44-
make install
53+
RUN autoreconf -i \
54+
&& ./configure \
55+
&& make clean \
56+
&& make \
57+
&& make install
4558

4659
# build the module
4760
WORKDIR /root/nginx
4861

49-
RUN NGINX_CONFIGURE_ARGUMENTS=`nginx -V 2>&1 | grep 'configure arguments:' | cut -d\ -f3- | sed "s/ --with-cc-opt='/ --with-cc-opt='-I\/tmp\/libredirectionio-master\/target /" | sed "s/ --with-ld-opt='/ --with-ld-opt='-L\/tmp\/libredirectionio-master\/target\/release /"` && \
50-
NGINX_MODULES_PATH=`nginx -V 2>&1 | gawk 'match($0,/--modules-path=(\S+?)/,a) {print a[1]}'` && \
51-
eval "./configure $NGINX_CONFIGURE_ARGUMENTS --add-dynamic-module=/tmp/libnginx-mod-redirectionio-master" && \
52-
make -j modules && \
53-
cp objs/ngx_http_redirectionio_module.so $NGINX_MODULES_PATH/ngx_http_redirectionio_module.so
62+
RUN NGINX_CONFIGURE_ARGUMENTS=`nginx -V 2>&1 | grep 'configure arguments:' | cut -d\ -f3- | sed "s/ --with-cc-opt='/ --with-cc-opt='-I\/tmp\/libredirectionio-master\/target /" | sed "s/ --with-ld-opt='/ --with-ld-opt='-L\/tmp\/libredirectionio-master\/target\/release /"` \
63+
&& NGINX_MODULES_PATH=`nginx -V 2>&1 | gawk 'match($0,/--modules-path=(\S+?)/,a) {print a[1]}'` \
64+
&& eval "./configure $NGINX_CONFIGURE_ARGUMENTS --add-dynamic-module=/tmp/libnginx-mod-redirectionio-master" \
65+
&& make -j modules \
66+
&& cp objs/ngx_http_redirectionio_module.so $NGINX_MODULES_PATH/ngx_http_redirectionio_module.so
5467

5568
# Configuration
5669
COPY etc /etc

services/nginx/Dockerfile

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
FROM ubuntu:20.04
22

33
RUN DEBIAN_FRONTEND=noninteractive apt-get update \
4-
&& DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade -y
5-
6-
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y \
7-
apt-transport-https \
8-
gnupg2 \
9-
nginx \
10-
wget
4+
&& DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade -y \
5+
&& DEBIAN_FRONTEND=noninteractive apt-get install -y \
6+
apt-transport-https \
7+
gnupg2 \
8+
nginx \
9+
wget \
10+
&& apt-get clean \
11+
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
1112

1213
RUN wget -q -O - https://packages.redirection.io/gpg.key | apt-key add - \
1314
&& echo "deb https://packages.redirection.io/deb/stable/2 focal main" | tee -a /etc/apt/sources.list.d/packages_redirection_io_deb.list \
1415
&& apt-get update \
15-
&& apt-get install libnginx-mod-redirectionio
16+
&& apt-get install -y \
17+
libnginx-mod-redirectionio \
18+
&& apt-get clean \
19+
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
1620

1721
# Configuration
1822
COPY etc /etc

services/redirectionio-agent/Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ FROM alpine:3.12 as alpine
22

33
WORKDIR /tmp
44

5-
RUN apk add --no-cache wget ca-certificates
6-
RUN wget https://packages.redirection.io/dist/stable/2/any/redirectionio-agent-latest_any_amd64.tar.gz
7-
RUN tar -xzvf redirectionio-agent-latest_any_amd64.tar.gz && mkdir -p /tmp/var/lib/redirectionio
5+
RUN apk add --no-cache wget ca-certificates \
6+
&& wget https://packages.redirection.io/dist/stable/2/any/redirectionio-agent-latest_any_amd64.tar.gz \
7+
&& tar -xzvf redirectionio-agent-latest_any_amd64.tar.gz
88

99
FROM scratch
1010

1111
# Binary copied from tar
12-
COPY --from=alpine /tmp/redirection-agent/redirectionio-agent .
12+
COPY --from=alpine /tmp/redirection-agent/redirectionio-agent /usr/local/bin/redirectionio-agent
1313

1414
# Configuration, can be replaced by your own
1515
COPY etc /etc
@@ -20,4 +20,4 @@ COPY --from=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
2020
# Cache storage for rules
2121
VOLUME /var/lib/redirectionio
2222

23-
CMD ["/redirectionio-agent"]
23+
CMD ["/usr/local/bin/redirectionio-agent"]

0 commit comments

Comments
 (0)