Skip to content

Commit

Permalink
Merge pull request #1 from julian-eggers/init
Browse files Browse the repository at this point in the history
init
  • Loading branch information
julian-eggers authored Nov 11, 2018
2 parents a2aa234 + 148bbe3 commit 489af15
Show file tree
Hide file tree
Showing 41 changed files with 2,304 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/target/
/.factorypath
/.classpath
/.settings/
/.project
16 changes: 16 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
language: java

jdk:
- oraclejdk11

cache:
directories:
- $HOME/.m2

install: mvn clean verify

before_install:
- wget -O ~/codacy-coverage-reporter-assembly.jar https://github.com/codacy/codacy-coverage-reporter/releases/download/4.0.5/codacy-coverage-reporter-4.0.5-assembly.jar

after_success:
- java -jar ~/codacy-coverage-reporter-assembly.jar report -l Java -r target/site/jacoco/jacoco.xml
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM openjdk:11-jre-slim
EXPOSE 8080
ADD target/docd.jar docd.jar
ENTRYPOINT ["java", "-jar", "-Dfile.encoding=UTF-8", "-Djava.security.egd=file:/dev/./urandom", "docd.jar"]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017 Julian Eggers

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
119 changes: 119 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
docd
====

[![Codacy Badge](https://api.codacy.com/project/badge/Grade/61cc56dec92b41e39ca8afbb6df93bea)](https://www.codacy.com/app/eggers-julian/docd)
[![Codacy Badge](https://api.codacy.com/project/badge/Coverage/61cc56dec92b41e39ca8afbb6df93bea)](https://www.codacy.com/app/eggers-julian/docd)
[![Build Status](https://travis-ci.com/julian-eggers/docd.svg?branch=master)](https://travis-ci.com/julian-eggers/docd)

Automatic redeploy for docker swarm services

## Docker
[Dockerhub](https://hub.docker.com/r/jeggers/docd/)

## Setup
1. Start docd on a swarm-manager
2. Choose a trigger-method (Messaging, WebHook or REST)
3. Trigger deployments for existing services

```
docker service create \
--name=docd \
--publish mode=host,target=8080 \
--mount type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock \
jeggers/docd:latest
```


## Deployments
- via Messaging (AWS SQS or RabbitMQ)
- via WebHook (Dockerhub)
- via REST

### Messaging
#### AWS SQS
| Property | Required | Default | Example |
| -------- | -------- | ------- | ---- |
| --webhookevent.queue.awssqs.access-key | yes | | [Policy](https://github.com/julian-eggers/docd/wiki/AWS-SQS#policy) |
| --webhookevent.queue.awssqs.secret-key | yes | | |
| --webhookevent.queue.awssqs.region | yes | | [Regions](https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/regions/Regions.html) |
| --webhookevent.queue.awssqs.queue-name | yes | | |

Note: Every cluster needs its own queue-name!

#### RabbitMQ
| Property | Required | Default | Example |
| - | - | - | - |
| --webhookevent.queue.rabbitmq.hosts | yes | | localhost |
| --webhookevent.queue.rabbitmq.username | no | guest | |
| --webhookevent.queue.rabbitmq.password | no | guest | |
| --webhookevent.queue.rabbitmq.exchange.name | no | io.docker | |
| --webhookevent.queue.rabbitmq.routing-key | no | webHookEvent | |
| --webhookevent.queue.rabbitmq.queue-name | no | com.itelg.docker.docd.webhookevent | |

Note: Every cluster needs its own queue-name!


### WebHook
#### Dockerhub
- POST: http://docd/webhook/dockerhub
- Body: [WebHookEvent](https://docs.docker.com/docker-hub/webhooks/)

### REST
- POST: http://docd/service/{serviceName}/redeploy


## Selection (Whitelist/Blacklist)
docd supports a white- and blacklist-mode.

Blacklist is the default, so every service is automatically deployed.
Preferred usage: Test-systems

To disable deployments in blacklist-mode a service-label named "DAD_SELECTION_BLOCKED" must be set.
```
docker service create \
--name=docd \
jeggers/docd:latest \
--service.selection.mode=BLACKLIST
docker service create \
--name=dummy-service \
--label DAD_SELECTION_BLOCKED=true \
dummy/service:latestt
```

In whitelist-mode you have to explicitly enable every service.
Preferred usage: Staging-systems or small production-systems

To enable deployments in whitelist-mode a service-label named "DAD_SELECTION_ALLOWED" must be set.
```
docker service create \
--name=docd \
jeggers/docd:latest \
--service.selection.mode=WHITELIST
docker service create \
--name=dummy-service \
--label DAD_SELECTION_ALLOWED=true \
dummy/service:latest
```

## REST
- POST/GET: http://docd/service/{serviceName}/allow
- POST/GET: http://docd/service/{serviceName}/block
- POST/GET: http://docd/service/{serviceName}/redeploy
- DELETE: http://docd/service/{serviceName}
- GET: http://docd/service/{serviceName}



## Build & Release

### Build
```
mvn clean package dockerfile:build
```

### Release
```
mvn clean package dockerfile:build dockerfile:tag@tag-latest dockerfile:tag@tag-version dockerfile:push@push-latest dockerfile:push@push-version github-release:release
```
Loading

0 comments on commit 489af15

Please sign in to comment.