Skip to content

Commit 4d37ce0

Browse files
authored
Merge pull request #667 from CodeNow/fix-image-builder-push
Fix tagging of image builder
2 parents a44b903 + ba22cc4 commit 4d37ce0

8 files changed

Lines changed: 44 additions & 25 deletions

File tree

ansible/delta-hosts/hosts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ delta-consul-c
3737
[user-vault]
3838
localhost
3939

40+
[user-local]
41+
localhost
42+
4043
[worker]
4144
localhost
4245

ansible/gamma-hosts/hosts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ gamma-consul-c
4141
[user-vault]
4242
localhost
4343

44+
[user-local]
45+
localhost
46+
4447
[worker]
4548
localhost
4649

ansible/group_vars/alpha-image-builder.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
app_name: image-builder
22
name: "{{ app_name }}"
3-
# namespace (can include "registry.runnable.com:")
4-
image_builder_docker_namespace: "{{ registry_host }}/runnable/image-builder"
5-
app_repo: git@github.com:CodeNow/{{ app_name }}.git
3+
4+
repo: git@github.com:CodeNow/{{ name }}.git
65

76
# consul values
87
consul_values:

ansible/image-builder.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
---
2+
- hosts: user-local
3+
vars_files:
4+
- group_vars/alpha-image-builder.yml
5+
roles:
6+
- { role: build_with_dockerfile }
7+
28
- hosts: "{{ dock | default('docks') }}"
39
vars_files:
410
- group_vars/alpha-image-builder.yml
511
roles:
6-
- { role: notify, tags: [notify] }
7-
- { role: node, tags: [setup] }
8-
- { role: git_repo }
9-
- { role: image-builder }
12+
- { role: pull-image }
1013
- { role: consul_value, tags: [consul_value] }

ansible/roles/build_with_dockerfile/tasks/main.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,20 @@
3030
become: yes
3131
command: docker build {{ build_args | default("") }} --tag="{{ container_image }}:{{ container_tag }}" "{{ build_dir }}/{{ name }}/repo"
3232

33+
- name: login to registry
34+
delegate_to: "{{ builder }}"
35+
tags: deploy, build
36+
become: yes
37+
command: docker login -u {{ registry_username }} -p {{ registry_token }} -e "info@runnable.com" {{ registry_host }}
38+
3339
- name: push docker image
3440
delegate_to: "{{ builder }}"
3541
tags: deploy, build
3642
become: yes
37-
ignore_errors: True
3843
command: docker push {{ container_image }}:{{ container_tag }}
44+
45+
- name: logout of registry
46+
delegate_to: "{{ builder }}"
47+
tags: deploy, build
48+
become: yes
49+
command: docker logout {{ registry_host }}

ansible/roles/builder/tasks/main.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
- name: set number of images built
3232
tags: deploy, build
3333
set_fact:
34+
# Quay IO includes deleted images in this query through the `end_ts` property
3435
no_images_found: "{{ currently_built_tags|json_query('json.tags')|length == 0 }}"
3536

3637
- name: set number of images built
@@ -192,4 +193,4 @@
192193
tags: deploy, build
193194
when: build_image
194195
become: yes
195-
command: docker logout
196+
command: docker logout {{ registry_host }}

ansible/roles/image-builder/tasks/main.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
- name: login to registry
3+
tags: deploy
4+
become: yes
5+
command: docker login -u {{ registry_username }} -p {{ registry_token }} -e "info@runnable.com" {{ registry_host }}
6+
7+
- name: pull image
8+
tags: deploy
9+
become: true
10+
command: docker pull {{ container_image }}:{{ container_tag }}
11+
12+
- name: logout of registry
13+
tags: deploy
14+
become: yes
15+
command: docker logout {{ registry_host }}

0 commit comments

Comments
 (0)