diff --git a/README.md b/README.md index 852bf56..d1ccd3f 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,11 @@ A collection of delicious docker recipes. - [x] node-red :+1: - [x] mosquitto :+1: +## Automation + +- [x] drone-rsync-arm +- [x] jenkins-arm :beetle: + ## Daemon - [x] alpine-arm :+1: @@ -141,7 +146,6 @@ A collection of delicious docker recipes. - [x] hugo - [x] hugo-arm - [x] jamapi -- [x] jenkins-arm :beetle: - [x] joomla - [x] json-server - [x] magento diff --git a/drone-rsync-arm/Dockerfile b/drone-rsync-arm/Dockerfile new file mode 100644 index 0000000..7e176ea --- /dev/null +++ b/drone-rsync-arm/Dockerfile @@ -0,0 +1,12 @@ +# +# Dockerfile for drone-rsync-arm +# + +FROM easypi/alpine-arm +MAINTAINER EasyPi Software Foundation + +RUN apk add --no-cache bash ca-certificates curl openssh-client rsync +RUN curl -sSL https://github.com/Drillster/drone-rsync/raw/master/upload.sh > /usr/local/bin/upload.sh +RUN chmod +x /usr/local/bin/upload.sh + +ENTRYPOINT ["upload.sh"] diff --git a/drone-rsync-arm/LICENSE b/drone-rsync-arm/LICENSE new file mode 100644 index 0000000..f71d57d --- /dev/null +++ b/drone-rsync-arm/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2016 Drillster BV + +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. diff --git a/drone-rsync-arm/README.md b/drone-rsync-arm/README.md new file mode 100644 index 0000000..55a8eeb --- /dev/null +++ b/drone-rsync-arm/README.md @@ -0,0 +1,93 @@ +> A fork of https://github.com/Drillster/drone-rsync + +Use the Rsync plugin to synchronize files to remote hosts, and execute arbitrary commands on those hosts. + +## Config +The following parameters are used to configure the plugin: +- **user** - user to log in as on the remote machines, defaults to `root` +- **key** - private SSH key for the remote machines +- **hosts** - hostnames or ip-addresses of the remote machines +- **port** - port to connect to on the remote machines, defaults to `22` +- **source** - source folder to synchronize from, defaults to `./` +- **target** - target folder on remote machines to synchronize to +- **include** - rsync include filter +- **exclude** - rsync exclude filter +- **recursive** - recursively synchronize, defaults to `false` +- **delete** - delete target folder contents, defaults to `false` +- **script** - list of commands to execute on remote machines + +It is highly recommended to put your **key** into a secret so it is not exposed to users. This can be done using the drone-cli. + +```sh +drone secret add octocat/hello-world RSYNC_KEY @path/to/.ssh/id_rsa +``` + +Add the secret to your `.drone.yml`: +```yaml +pipeline: + rsync: + image: easypi/drone-rsync-arm + user: some-user + key: ${RSYNC_KEY} + hosts: + - remote1 + source: ./dist + target: ~/packages +``` + +Then sign the YAML file after all secrets are added. + +```sh +drone sign octocat/hello-world +``` + +See the [Secret Guide](http://readme.drone.io/usage/secret-guide/) for additional information on secrets. + +## Examples +```yaml +pipeline: + rsync: + image: easypi/drone-rsync-arm + user: some-user + key: ${RSYNC_KEY} + hosts: + - remote1 + - remote2 + source: ./dist + target: ~/packages + include: + - "app.tar.gz" + - "app.tar.gz.md5" + exclude: + - "**.*" + script: + - cd ~/packages + - md5sum -c app.tar.gz.md5 + - tar -xf app.tar.gz -C ~/app +``` + +The example above illustrates a situation where an app package (`app.tar.gz`) will be deployed to 2 remote hosts (`remote1` and `remote2`). An md5 checksum will be deployed as well. After deploying, the md5 checksum is used to check the deployed package. If successful the package is extracted. + +## Important +The script passed to **script** will be executed on remote machines directly after rsync completes to deploy the files. It will be executed step by step until a command returns a non-zero exit-code. If this happens, the entire plugin will exit and fail the build. + + +## SSH key secret in Drone >= 0.6 + +Secret injection has changed for Drone 0.6 and up. Register your SSH key secret using the drone-cli. + +```sh +drone secret update \ + --repository your/repo \ + --name plugin_key \ + --value @./id_rsa.pub \ + --image easypi/drone-rsync-arm +``` + +Do not add a `key` parameter in `.drone.yml` configuration, but add: + +``` +secrets: [ plugin_key ] +``` + +Using any other name will not work.