Adds webhooks service with site reploy webhook

master
Abhinav Sarkar 2018-06-20 18:25:14 +00:00
parent f01472bbeb
commit 6ac456b193
5 changed files with 47 additions and 0 deletions

View File

@ -85,3 +85,9 @@ services:
- db
site:
image: abhin4v/abhinavsarkar.net:latest
hooks:
build:
context: ./webhooks
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- .:/opt/space

23
nginx-conf/hooks.conf Normal file
View File

@ -0,0 +1,23 @@
server {
listen 443 ssl;
server_name hooks.abhinavsarkar.net;
ssl_certificate /etc/nginx/certs/fullchain1.pem;
ssl_certificate_key /etc/nginx/certs/privkey1.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
proxy_set_header X-Real-IP $remote_addr; # pass on real client IP
location / {
proxy_pass http://hooks:9000;
}
}
server {
listen 80;
server_name hooks.abhinavsarkar.net;
return 301 https://$host$request_uri;
}

7
webhooks/Dockerfile Normal file
View File

@ -0,0 +1,7 @@
FROM almir/webhook
RUN apk add --update docker py-pip \
&& pip install docker-compose \
&& rm -rf /var/cache/apk/*
COPY hooks.json /etc/webhook/hooks.json
COPY redeploy-site.sh /var/scripts/redeploy-site.sh
CMD ["-verbose", "-hooks=/etc/webhook/hooks.json"]

7
webhooks/hooks.json Normal file
View File

@ -0,0 +1,7 @@
[
{
"id": "redeploy-site",
"execute-command": "/var/scripts/redeploy-site.sh",
"command-working-directory": "/opt/space"
}
]

4
webhooks/redeploy-site.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/sh
docker-compose pull site
docker-compose up -d --build site