From: Ismaƫl Bouya Date: Wed, 21 Nov 2018 19:21:18 +0000 (+0100) Subject: Add docker images building X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=501e9127cab085c0454647e9793b9a6570fe7028;p=perso%2FImmae%2FConfig%2FAnsible.git Add docker images building --- diff --git a/roles/contexts/fretlink/defaults/main.yml b/roles/contexts/fretlink/defaults/main.yml index 101c9aa..078e3da 100644 --- a/roles/contexts/fretlink/defaults/main.yml +++ b/roles/contexts/fretlink/defaults/main.yml @@ -14,3 +14,5 @@ zeal_roles: - Rust - Vim - XSLT +docker_images: + - ["mongo", "3.6-hacker", "mongo_hacker"] diff --git a/roles/contexts/fretlink/files/docker/mongo_hacker/Dockerfile b/roles/contexts/fretlink/files/docker/mongo_hacker/Dockerfile new file mode 100644 index 0000000..019e159 --- /dev/null +++ b/roles/contexts/fretlink/files/docker/mongo_hacker/Dockerfile @@ -0,0 +1,10 @@ +FROM mongo:3.6 + +RUN apt-get update \ + && apt-get install -y git \ + && apt-get install -y build-essential \ + && git clone --depth=1 https://github.com/TylerBrock/mongo-hacker.git \ + && rm -rf ~/.mongorc.js \ + && cd mongo-hacker \ + && make install + diff --git a/roles/contexts/fretlink/files/workdir/start b/roles/contexts/fretlink/files/workdir/start index 911c28d..b587efe 100755 --- a/roles/contexts/fretlink/files/workdir/start +++ b/roles/contexts/fretlink/files/workdir/start @@ -27,7 +27,7 @@ function start_app() { trap 'make stop' EXIT if ! docker top mongo_container 2>/dev/null; then - docker run -d --name mongo_container -p 27017:27017 --rm -v $(pwd)/appdata:/data/db mongo:3.6 + docker run -d --name mongo_container -p 27017:27017 --rm -v $(pwd)/appdata:/data/db mongo:3.6-hacker echo "Waiting until mongo is started" sleep 10 fi diff --git a/roles/contexts/fretlink/tasks/main.yml b/roles/contexts/fretlink/tasks/main.yml index ce69e02..99d39b3 100644 --- a/roles/contexts/fretlink/tasks/main.yml +++ b/roles/contexts/fretlink/tasks/main.yml @@ -111,3 +111,30 @@ dest: "$XDG_DATA_HOME/bash_completion/_{{ item }}" loop: - fl_tmux_dev +- name: docker images + block: + - name: check missing docker images + register: docker_missing_images + shell: '[ -n "$(docker image ls -q {{ item.0 }}:{{ item.1 }})" ] || echo "missing"' + loop: "{{ docker_images }}" + check_mode: no + changed_when: docker_missing_images.stdout != "" + - name: Ask for Docker images + when: docker_missing_images.changed + pause: + prompt: "install Fretlink Docker images ? [y/N]" + register: docker_install_images + check_mode: no + - name: install custom docker images + when: item.2 is not none and docker_missing_images.changed and docker_install_images.user_input.startswith("y") + docker_image: + path: "./roles/contexts/fretlink/files/docker/{{ item.2 }}" + tag: "{{ item.1 }}" + name: "{{ item.0 }}" + loop: "{{ docker_images }}" + - name: install repository docker images + when: item.2 is none and docker_missing_images.changed and docker_install_images.user_input.startswith("y") + docker_image: + tag: "{{ item.1 }}" + name: "{{ item.0 }}" + loop: "{{ docker_images }}"