Skip to content

Commit bf13ba5

Browse files
committed
Broke apart docker file into build and test, added shell script
Broke apart docker file into build and test, added shell script
1 parent cb8a18e commit bf13ba5

File tree

4 files changed

+77
-15
lines changed

4 files changed

+77
-15
lines changed

Dockerfile

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
FROM centos:7
22

3-
MAINTAINER Tesla Government email: [email protected]
3+
LABEL maintainer="TeslaGov" email="[email protected]"
44

55
ENV LD_LIBRARY_PATH=/usr/local/lib
66

7-
COPY ./resources/nginx.repo /etc/yum.repos.d/nginx.repo
8-
97
RUN yum -y update && \
108
yum -y groupinstall 'Development Tools' && \
119
yum -y install pcre-devel pcre zlib-devel openssl-devel wget cmake check-devel check
@@ -26,7 +24,7 @@ RUN wget https://github.com/akheron/jansson/archive/v2.10.zip && \
2624
rm v2.10.zip && \
2725
ln -sf jansson-2.10 jansson && \
2826
cd /root/dl/jansson && \
29-
cmake . -DJANSSON_BUILD_SHARED_LIBS=1 -DJANSSON_BUILD_DOCS=OFF &&
27+
cmake . -DJANSSON_BUILD_SHARED_LIBS=1 -DJANSSON_BUILD_DOCS=OFF && \
3028
make && \
3129
make check && \
3230
make install
@@ -50,14 +48,3 @@ RUN wget http://nginx.org/download/nginx-1.12.0.tar.gz && \
5048
cd /root/dl/nginx && \
5149
./configure --with-compat --add-dynamic-module=../ngx-http-auth-jwt-module --with-cc-opt='-std=gnu99' && \
5250
make modules
53-
54-
# setup a test for the new module
55-
RUN cp -r /usr/share/nginx/html /usr/share/nginx/secure
56-
COPY ./resources/test-jwt-nginx.conf /etc/nginx/conf.d/test-jwt-nginx.conf
57-
# download and run nginx binary
58-
RUN yum -y install nginx-1.12.0 && \
59-
cp /root/dl/nginx/objs/ngx_http_auth_jwt_module.so /etc/nginx/modules/. && \
60-
nginx
61-
62-
EXPOSE 8000
63-

build.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
# build
4+
DOCKER_IMAGE_NAME=jwt-nginx
5+
docker build -t ${DOCKER_IMAGE_NAME} .
6+
CONTAINER_ID=$(docker run -itd ${DOCKER_IMAGE_NAME} sh)
7+
8+
# setup test
9+
rm -rf ./lib
10+
rm -rf ./modules
11+
mkdir modules
12+
DOCKER_TEST_IMAGE_NAME=jwt-nginx-test
13+
docker build -t ${DOCKER_TEST_IMAGE_NAME} test/.
14+
CONTAINER_TEST_ID=$(docker run -p 8000:8000 -itd ${DOCKER_TEST_IMAGE_NAME} sh)
15+
docker cp ${CONTAINER_ID}:/usr/local/lib .
16+
docker cp lib ${CONTAINER_TEST_ID}:/usr/local
17+
docker cp ${CONTAINER_ID}:/root/dl/nginx/objs/ngx_http_auth_jwt_module.so modules/.
18+
docker cp modules/ngx_http_auth_jwt_module.so ${CONTAINER_TEST_ID}:/usr/lib64/nginx/modules/.
19+
docker cp resources/test-jwt-nginx.conf ${CONTAINER_TEST_ID}:/etc/nginx/conf.d/test-jwt-nginx.conf
20+
docker cp resources/nginx.conf ${CONTAINER_TEST_ID}:/etc/nginx/.
21+
22+
docker exec -d ${CONTAINER_TEST_ID} /bin/bash -c "export LD_LIBRARY_PATH=/usr/local/lib && nginx"
23+
24+
25+
26+

resources/nginx.conf

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
user nginx;
3+
worker_processes 1;
4+
5+
error_log /var/log/nginx/error.log warn;
6+
pid /var/run/nginx.pid;
7+
8+
load_module modules/ngx_http_auth_jwt_module.so;
9+
10+
events {
11+
worker_connections 1024;
12+
}
13+
14+
15+
http {
16+
include /etc/nginx/mime.types;
17+
default_type application/octet-stream;
18+
19+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
20+
'$status $body_bytes_sent "$http_referer" '
21+
'"$http_user_agent" "$http_x_forwarded_for"';
22+
23+
access_log /var/log/nginx/access.log main;
24+
25+
sendfile on;
26+
#tcp_nopush on;
27+
28+
keepalive_timeout 65;
29+
30+
#gzip on;
31+
32+
include /etc/nginx/conf.d/*.conf;
33+
}
34+

test/Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM centos:7
2+
3+
LABEL maintainer="TeslaGov" email="[email protected]"
4+
5+
ENV LD_LIBRARY_PATH=/usr/local/lib
6+
7+
COPY nginx.repo /etc/yum.repos.d/nginx.repo
8+
9+
# setup a test for the new module
10+
# download and run nginx binary
11+
RUN yum -y update && \
12+
yum -y install nginx-1.12.0 && \
13+
cp -r /usr/share/nginx/html /usr/share/nginx/secure
14+
15+
EXPOSE 8000

0 commit comments

Comments
 (0)