]> git.immae.eu Git - perso/Immae/Config/Ansible.git/commitdiff
Add docker images building
authorIsmaël Bouya <ismael.bouya@fretlink.com>
Wed, 21 Nov 2018 19:21:18 +0000 (20:21 +0100)
committerIsmaël Bouya <ismael.bouya@fretlink.com>
Wed, 21 Nov 2018 19:21:18 +0000 (20:21 +0100)
roles/contexts/fretlink/defaults/main.yml
roles/contexts/fretlink/files/docker/mongo_hacker/Dockerfile [new file with mode: 0644]
roles/contexts/fretlink/files/workdir/start
roles/contexts/fretlink/tasks/main.yml

index 101c9aab8f299464652a863ad0ba744819f71270..078e3da75d739d3aebb50f2da5a303c83886eb02 100644 (file)
@@ -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 (file)
index 0000000..019e159
--- /dev/null
@@ -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
+
index 911c28de40b5095cf069715c53b2eda7cd552521..b587efe8f8c009bf88b63db28106eb7218f27bc3 100755 (executable)
@@ -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
index ce69e02ee48ad4090f0be05d8a9177f41bcc64a9..99d39b3752b4a7cd4d3dde6db6dd7add42333669 100644 (file)
         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 }}"