-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.travis.yml
74 lines (67 loc) · 2.81 KB
/
.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
sudo: required
language: python
services:
- docker
matrix:
include:
- python:
env:
- NAME="NGINX Container"
- RUN_IMAGE_NAME=nginx-modsecurity
- RUN_IMAGE_NAME_COMPILE=modsecurity-compile
- IMAGE_NAME=vdveldet/nginx-modsecurity
- IMAGE_COMPILE=nginx-compile
- DOCKERFILE_COMPILE=Dockerfile_compile_debian
- DOCKERFILE=Dockerfile_debian
- VERSION=0.1
- NGINX_VERSION=1.17.5
- MODSECURITY=3.0
- MODSECURITY_RELEASE=3
install: true
script: pytest || true ? # This is needed for the build to complete
before_install:
# First a Compile docker that will deliver the .deb an .so file
- docker build --file $DOCKERFILE_COMPILE -t $IMAGE_COMPILE --build-arg VERSION --build-arg NGINX_VERSION --build-arg MODSECURITY --build-arg MODSECURITY_RELEASE .
- docker run -d -p 127.0.0.1:80:8080 --name $RUN_IMAGE_NAME_COMPILE $IMAGE_COMPILE # Test is build is running
- docker ps -a
- curl http://127.0.0.1/nginx_status # This URL is configured in the docker
- docker logs $RUN_IMAGE_NAME_COMPILE
- mkdir deb
- docker cp $RUN_IMAGE_NAME_COMPILE:/ModSecurity/modsecurity_${MODSECURITY}-${MODSECURITY_RELEASE}_amd64.deb deb/
- docker cp $RUN_IMAGE_NAME_COMPILE:/usr/share/nginx/modules/ngx_http_modsecurity_module.so deb/
- docker cp $RUN_IMAGE_NAME_COMPILE:/tmp/nginx-module-modsecurity3_${NGINX_VERSION}.deb deb/
- ls -l deb/
- docker stop $RUN_IMAGE_NAME_COMPILE
# From here the production docker is build
- docker build --file $DOCKERFILE -t $IMAGE_NAME --build-arg VERSION --build-arg NGINX_VERSION --build-arg MODSECURITY --build-arg MODSECURITY_RELEASE .
- docker run -d -p 127.0.0.1:80:8080 --name $RUN_IMAGE_NAME $IMAGE_NAME # Test is build is running
- docker ps -a
- curl http://127.0.0.1/nginx_status || true # This URL is configured in the docker
- curl http://127.0.0.1/index.html?testparam=test || true
- docker logs $RUN_IMAGE_NAME
- echo "$DOCKERHUB_PASSWD" | docker login --username "$DOCKERHUB_USERNAME" --password-stdin docker.io
- docker tag "$IMAGE_NAME" "docker.io/${IMAGE_NAME}:latest"
- docker tag "$IMAGE_NAME" "docker.io/${IMAGE_NAME}:${VERSION}"
deploy:
- provider: script
script: docker push "docker.io/${IMAGE_NAME}:latest"
on:
branch: master
- provider: script
script: docker push "docker.io/${IMAGE_NAME}:${VERSION}"
on:
branch: master
- provider: releases
api_key: ${GH_TOKEN}
file: deb/nginx-module-modsecurity3_${NGINX_VERSION}.deb
skip_cleanup: true
on:
tags: true
- provider: releases
api_key: ${GH_TOKEN}
file: deb/modsecurity_${MODSECURITY}-${MODSECURITY_RELEASE}_amd64.deb
skip_cleanup: true
on:
tags: true
after_script:
- docker pull "docker.io/${IMAGE_NAME}:latest"