Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 12 additions & 19 deletions ansible/ci-build-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,17 @@
chdir: "{{ ansible_env.GITHUB_WORKSPACE | default(collector_root) }}"
target: builder

- name: Retag collector builder image to arch specific
community.docker.docker_image:
name: "quay.io/stackrox-io/collector-builder:{{ ansible_env.COLLECTOR_BUILDER_TAG }}"
repository: "quay.io/stackrox-io/collector-builder:{{ ansible_env.COLLECTOR_BUILDER_TAG }}-{{ arch }}"
source: local

- name: Untag collector builder image to prevent issues with multiarch
community.docker.docker_image:
name: "quay.io/stackrox-io/collector-builder:{{ ansible_env.COLLECTOR_BUILDER_TAG }}"
state: absent

- name: Login to quay.io
community.docker.docker_login:
registry_url: quay.io
username: "{{ stackrox_io_username }}"
password: "{{ stackrox_io_password }}"

- name: Push builder image to quay.io/stackrox-io
community.docker.docker_image:
name: "quay.io/stackrox-io/collector-builder:{{ ansible_env.COLLECTOR_BUILDER_TAG }}-{{ arch }}"
push: true
source: local
import_tasks: push-with-crane.yml
vars:
src_image: "quay.io/stackrox-io/collector-builder:{{ ansible_env.COLLECTOR_BUILDER_TAG }}"
dst_image: "quay.io/stackrox-io/collector-builder:{{ ansible_env.COLLECTOR_BUILDER_TAG }}-{{ arch }}"

- name: Login to quay.io
community.docker.docker_login:
Expand All @@ -47,11 +36,15 @@
password: "{{ rhacs_eng_password }}"

- name: Push builder image to quay.io/rhacs-eng
import_tasks: push-with-crane.yml
vars:
src_image: "quay.io/stackrox-io/collector-builder:{{ ansible_env.COLLECTOR_BUILDER_TAG }}"
dst_image: "quay.io/rhacs-eng/collector-builder:{{ ansible_env.COLLECTOR_BUILDER_TAG }}-{{ arch }}"

- name: Untag collector builder image to prevent issues with multiarch
community.docker.docker_image:
name: "quay.io/stackrox-io/collector-builder:{{ ansible_env.COLLECTOR_BUILDER_TAG }}-{{ arch }}"
repository: "quay.io/rhacs-eng/collector-builder:{{ ansible_env.COLLECTOR_BUILDER_TAG }}-{{ arch }}"
push: true
source: local
name: "quay.io/stackrox-io/collector-builder:{{ ansible_env.COLLECTOR_BUILDER_TAG }}"
state: absent

- name: Print builder images pushed
debug:
Expand Down
31 changes: 12 additions & 19 deletions ansible/ci-build-collector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,17 @@
# ensure this action is printed
tags: [print_action]

- name: Retag collector image to arch specific
community.docker.docker_image:
name: "{{ collector_image }}"
repository: "{{ collector_image }}-{{ arch }}"
source: local

- name: Untag collector image to prevent issues with multiarch
community.docker.docker_image:
name: "{{ collector_image }}"
state: absent

- name: Login to quay.io
community.docker.docker_login:
registry_url: quay.io
username: "{{ stackrox_io_username }}"
password: "{{ stackrox_io_password }}"

- name: Push to quay.io/stackrox-io
community.docker.docker_image:
name: "{{ collector_image }}-{{ arch }}"
push: true
source: local
import_tasks: push-with-crane.yml
vars:
src_image: "{{ collector_image }}"
dst_image: "{{ collector_image }}-{{ arch }}"

- name: Login to quay.io
community.docker.docker_login:
Expand All @@ -57,11 +46,15 @@
password: "{{ rhacs_eng_password }}"

- name: Push to quay.io/rhacs-eng
import_tasks: push-with-crane.yml
vars:
src_image: "{{ collector_image }}"
dst_image: "{{ rhacs_eng_image }}-{{ arch }}"

- name: Untag collector image to prevent issues with multiarch
community.docker.docker_image:
name: "{{ collector_image }}-{{ arch }}"
repository: "{{ rhacs_eng_image }}-{{ arch }}"
push: true
source: local
name: "{{ collector_image }}"
state: absent

- name: Print images pushed
debug:
Expand Down
28 changes: 28 additions & 0 deletions ansible/push-with-crane.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
- name: Check if crane is available
ansible.builtin.stat:
path: /usr/local/bin/crane
register: crane_stat

- name: Install crane
when: not crane_stat.stat.exists
shell:
cmd: |
# Inspired by https://github.com/actions/runner-images/issues/13474#issuecomment-3893588930
CRANE_VERSION=v0.20.7
CRANE_PLATFORM={{ arch }}
case "${CRANE_PLATFORM}" in
amd64) CRANE_PLATFORM=x86_64 ;;
esac
curl -sL "https://github.com/google/go-containerregistry/releases/download/${CRANE_VERSION}/go-containerregistry_Linux_${CRANE_PLATFORM}.tar.gz" \
| tar xz -C /usr/local/bin crane

- name: Push image
shell:
cmd: |
TMPTAR=$(mktemp /tmp/image-XXXXXX.tar)
docker save "{{ src_image }}" -o "$TMPTAR" && crane push "$TMPTAR" "{{ dst_image }}"
RC=$?
rm -f "$TMPTAR"
exit $RC

Loading