├── .travis.yml
├── LICENSE
├── README.md
└── trigger_docker_builds.sh
/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: false
2 | language: generic
3 | git:
4 | depth: 5
5 | addons:
6 | apt:
7 | packages:
8 | - curl
9 |
10 | script:
11 | - date && time ./trigger_docker_builds.sh
12 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | BSD 3-Clause License
2 |
3 | Copyright (c) 2016, Izaak Beekman
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | * Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | * Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | * Neither the name of the copyright holder nor the names of its
17 | contributors may be used to endorse or promote products derived from
18 | this software without specific prior written permission.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | :moon: :whale: :hammer_and_wrench: nightly-docker-rebuild :package: :whale2: :sparkles:
4 | =======================================================================================
5 |
6 | Use [nightli.es] to rebuild N docker images on [hub.docker.com],
7 | [setup] takes less than two minutes! :zap:
8 |
9 | [![Build Status][build badge]][latest build]
10 | [![Maintained?][maintained badge]][commit history]
11 | [![GitHub forks][forks badge]][do fork]
12 | [![GitHub stars][stars badge]][home]
13 | [![GitHub watchers][watchers badge]][home]
14 | [![Twitter URL][twitter badge]][do tweet]
15 |
16 | [![Whale spout launcher animation][whale gif]][travis builds]
17 |
18 |
19 |
20 | Update
21 | ------
22 |
23 | Since I originally wrote this guide, [Travis-CI] has added
24 | [cron jobs](https://docs.travis-ci.com/user/cron-jobs/). This means,
25 | that you no longer need to enable and register with [nightli.es].
26 | The entire setup can be done with Travis-CI alone.
27 |
28 | Why
29 | ---
30 |
31 | I use this to rebuild
32 | [GCC trunk in a docker container][GH GCC trunk in docker] on a nightly
33 | basis. If you're interested, please take a look at
34 | [my automated docker hub setup][Dhub GCC trunk in docker].
35 |
36 | [Travis-CI] is great but long builds can
37 | time out, which is a giant PITA. Docker to the rescue! By using
38 | [docker with Travis-CI](https://docs.travis-ci.com/user/docker/) you
39 | get to skip long builds for dependencies. While Travis-CI itself can
40 | be used to build docker images, some will time out before the build
41 | can complete. However, [Docker Hub][hub.docker.com] can be used to
42 | rebuild docker images (and it's harder to time out here) *BUT*
43 | [nightli.es] can only be used to trigger Travis-CI builds.... hmmmmm
44 | :thinking: what to do? [Nightly-docker-rebuild][home] to the rescue!
45 | :tada:
46 |
47 | How
48 | ---
49 |
50 | 1. [Fork][do fork]
51 | 1. Clone: `git clone
52 | https://github.com//nightly-docker-rebuild && cd
53 | nightly-docker-rebuild`
54 | 1. Enable and setup [Travis-CI] (through the online UI or by
55 | following the following steps)
56 | 1. `[sudo] gem install travis`
57 | 1. `travis login`
58 | 1. `travis enable`
59 | 1. Get your Docker Hub project end point URL and token from
60 | `https://hub.docker.com/r///~/settings/automated-builds/`
61 | 1. create encrypted Travis-CI variable to store private end point and
62 | token: `travis env set DH_END_POINT_1
63 | https://registry.hub.docker.com/u///trigger//`
64 | 1. Repeat for an additional nighly builds you want to setup and
65 | increment the number on `DH_END_POINT_`
66 | 1. Go to [nightli.es] and enable `nightly-docker-rebuild` after
67 | [logging in][nightli.es login]
68 |
69 | ---
70 |
71 |
72 |
73 | [![GitHub followers][GH followers badge]][GH profile]
74 | [![Twitter Follow][twitter followers badge]][do follow me on twitter]
75 |
76 |
77 |
78 | [Travis-CI]: https://travis-ci.com
79 | [nightli.es]: https://nightli.es
80 | [nightli.es login]: https://nightli.es/login
81 | [hub.docker.com]: https://hub.docker.com
82 | [GH GCC trunk in docker]: https://github.com/zbeekman/nightly-gcc-trunk-docker-image
83 | [setup]: #how
84 | [whale gif]: http://i.giphy.com/4AC11GmQzFVKg.gif "Whale spout launcher animation"
85 | [travis builds]: https://travis-ci.org/zbeekman/nightly-docker-rebuild/builds "history of builds on Travis-CI"
86 | [build badge]: https://api.travis-ci.org/zbeekman/nightly-docker-rebuild.svg?branch=master
87 | [latest build]: https://travis-ci.org/zbeekman/nightly-docker-rebuild
88 | [maintained badge]: https://img.shields.io/maintenance/yes/2018.svg
89 | [commit history]: https://github.com/zbeekman/nightly-docker-rebuild/commits/master
90 | [forks badge]: https://img.shields.io/github/forks/zbeekman/nightly-docker-rebuild.svg?style=social&label=Fork
91 | [do fork]: https://github.com/zbeekman/nightly-docker-rebuild/fork
92 | [stars badge]: https://img.shields.io/github/stars/zbeekman/nightly-docker-rebuild.svg?style=social&label=Star
93 | [home]: https://github.com/zbeekman/nightly-docker-rebuild
94 | [watchers badge]: https://img.shields.io/github/watchers/zbeekman/nightly-docker-rebuild.svg?style=social&label=Watch
95 | [twitter badge]: https://img.shields.io/twitter/url/http/shields.io.svg?style=social
96 | [do tweet]: https://twitter.com/intent/tweet?hashtags=nightly%2Cdocker%2Cbuild&related=docker%2Ctravisci&text=Rebuild%20your%20docker%20images%20on%20a%20nightly%20basis%21&url=https%3A//github.com/zbeekman/nightly-docker-rebuild&via=zbeekman
97 | [GH followers badge]: https://img.shields.io/github/followers/zbeekman.svg?style=social&label=Follow
98 | [GH profile]: https://github.com/zbeekman
99 | [twitter followers badge]: https://img.shields.io/twitter/follow/zbeekman.svg?style=social&label=Follow
100 | [do follow me on twitter]: https://twitter.com/intent/follow?screen_name=zbeekman
101 | [Dhub GCC trunk in docker]: https://hub.docker.com/r/zbeekman/nightly-gcc-trunk-docker-image/
102 |
--------------------------------------------------------------------------------
/trigger_docker_builds.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Script to trigger nightly builds on Docker Hub using Travis-CI
4 | #
5 | # Iterates over encrypted Travis-CI variables named `DH_END_POINT*`
6 | # containing docker hub web hook endpoint URLs including the secret
7 | # token and sends '{"build": true}' POSTs to the URL.
8 | #
9 | # Copyright (c) 2016, Izaak Beekman
10 | # All rights reserved.
11 | #
12 | # Redistribution and use in source and binary forms, with or without
13 | # modification, are permitted provided that the following conditions are met:
14 | #
15 | # * Redistributions of source code must retain the above copyright notice, this
16 | # list of conditions and the following disclaimer.
17 | #
18 | # * Redistributions in binary form must reproduce the above copyright notice,
19 | # this list of conditions and the following disclaimer in the documentation
20 | # and/or other materials provided with the distribution.
21 | #
22 | # * Neither the name of the copyright holder nor the names of its
23 | # contributors may be used to endorse or promote products derived from
24 | # this software without specific prior written permission.
25 | #
26 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
30 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
34 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 |
37 | # set -o verbose
38 | set -o pipefail
39 | set -o nounset
40 | set -o errexit
41 |
42 | # Make sure you create encrypted variables `DH_END_POINT_1`,
43 | # `DH_END_POINT_2` ... `DH_END_POINT_` for each docker build you
44 | # want to trigger These end point URLs have your secret token in them
45 | # so make sure to use:
46 | # `travis env set DH_END_POINT_1 https://registry.hub.docker.com/u///trigger//`
47 |
48 | for DH_URL_W_TOKEN in ${!DH_END_POINT*}; do
49 | time curl -H "Content-Type: application/json" --data '{"build": true}' -X POST "${!DH_URL_W_TOKEN}" \
50 | && echo "Sent request to rebuild ${DH_URL_W_TOKEN%/*/}"
51 | done
52 |
53 | # other examples
54 | # # Trigger by docker tag name
55 | # $ curl -H "Content-Type: application/json" --data '{"docker_tag": "master"}' -X POST $DH_URL_W_TOKEN
56 | # # Trigger by Source branch named staging
57 | # $ curl -H "Content-Type: application/json" --data '{"source_type": "Branch", "source_name": "staging"}' -X POST $DH_URL_W_TOKEN
58 | # # Trigger by Source tag named v1.1
59 | # $ curl -H "Content-Type: application/json" --data '{"source_type": "Tag", "source_name": "v1.1"}' -X POST $DH_URL_W_TOKEN
60 |
--------------------------------------------------------------------------------