|
13 | 13 | set -o errexit |
14 | 14 | cd $(dirname $0)/.. |
15 | 15 |
|
| 16 | +# helper function to return the state of the container (true if running, false if not) |
| 17 | +is_running(){ |
| 18 | + local name=$1 |
| 19 | + local state=$(docker inspect --format "{{.State.Running}}" $name 2>/dev/null) |
| 20 | + |
| 21 | + if [[ "$state" == "false" ]]; then |
| 22 | + # the container is up but not running |
| 23 | + # we should remove it so we can bring up another |
| 24 | + docker rm $name |
| 25 | + fi |
| 26 | + echo $state |
| 27 | +} |
| 28 | + |
| 29 | +# helper function to get boot2docker ip if we are on a mac |
| 30 | +hostip=0.0.0.0 |
| 31 | +if command -v boot2docker >/dev/null 2>&1 ; then |
| 32 | + hostip="$(boot2docker ip)" |
| 33 | +fi |
| 34 | +# if the DOCKER_HOST variable exists, lets get the host ip from that |
| 35 | +if [[ ! -z "$DOCKER_HOST" ]]; then |
| 36 | + hostip="$(echo $DOCKER_HOST | grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}')" |
| 37 | +fi |
| 38 | + |
16 | 39 | # In order to talk to a letsencrypt client running on the host, the fake DNS |
17 | 40 | # client used in Boulder's start.py needs to know what the host's IP is from the |
18 | 41 | # perspective of the container. We try to figure it out automatically. If you'd |
19 | 42 | # like your Boulder instance to always talk to some other host, you can set |
20 | 43 | # FAKE_DNS to that host's IP address. |
21 | 44 | if [ -z "${FAKE_DNS}" ] ; then |
22 | | - FAKE_DNS=$(ifconfig docker0 | sed -n 's/ *inet addr:\([0-9.]\+\).*/\1/p') |
| 45 | + FAKE_DNS=$(/sbin/ifconfig docker0 | sed -n 's/ *inet addr:\([0-9.]\+\).*/\1/p') |
| 46 | +fi |
| 47 | + |
| 48 | +if [[ "$(is_running boulder-mysql)" != "true" ]]; then |
| 49 | + # bring up mysql mariadb container |
| 50 | + docker run -d \ |
| 51 | + --net host \ |
| 52 | + -p 3306:3306 \ |
| 53 | + -e MYSQL_ALLOW_EMPTY_PASSWORD=yes \ |
| 54 | + --name boulder-mysql \ |
| 55 | + mariadb:10 |
| 56 | +fi |
| 57 | + |
| 58 | +if [[ "$(is_running boulder-rabbitmq)" != "true" ]]; then |
| 59 | + # bring up rabbitmq container |
| 60 | + docker run -d \ |
| 61 | + --net host \ |
| 62 | + -p 5672:5672 \ |
| 63 | + --name boulder-rabbitmq \ |
| 64 | + rabbitmq:3 |
23 | 65 | fi |
24 | 66 |
|
25 | | -# build the docker images |
26 | | -docker-compose build |
| 67 | +# build the boulder docker image |
| 68 | +docker build --rm --force-rm -t letsencrypt/boulder . |
27 | 69 |
|
| 70 | +# run the boulder container |
28 | 71 | # The excluding `-d` command makes the instance interactive, so you can kill |
29 | | -# all containers with Ctrl-C. |
30 | | -docker-compose up |
| 72 | +# the boulder container with Ctrl-C. |
| 73 | +docker run --rm -it \ |
| 74 | + --net host \ |
| 75 | + -p 4000:4000 \ |
| 76 | + -e MYSQL_CONTAINER=yes \ |
| 77 | + --name boulder \ |
| 78 | + letsencrypt/boulder |
0 commit comments