-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_image_from_git.yml
38 lines (38 loc) · 1.09 KB
/
build_image_from_git.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
---
- name: Build Docker Image From Git Repo and Push To Harbor
hosts: david-lab
tasks:
- name: Install dockerplugin
pip:
name: docker
- name: Retrive Git Project and pull locally
git:
repo: "{{ path }}"
dest: "/tmp/project"
clone: yes
- name: Login To Docker
docker_login:
username: "{{ userName }}"
password: "{{ password }}"
- name: Build Docker image from Dockerfile
docker_image:
build:
path: "/tmp/project"
name: "{{ image }}"
tag: "{{ tag }}"
push: yes
source: build
- name: Tag Latest If Asked For
docker_image:
name: "{{ image }}:{{ tag }}"
repository: "{{ image }}:latest"
force_tag: yes
source: local
push: yes
when: tag_latest == "True"
- name: Delete Local Copy of Git Repo
file:
state: absent
path: "/tmp/project"
...
#wget -q https://{{image}}/tags -O - | python3 -c "import sys,json;print(sorted([d['name'] for d in (json.load(sys.stdin)['results']) if d['name'] != 'latest'],reverse=True))" ---> to Get a list of current used tags