CI: test build docker image

Change-Id: Ia8ce0d8ec8f099501a39dc8bdff53a394bd53fea
This commit is contained in:
wu.chunyang 2022-11-09 22:52:49 +08:00
parent 3789a3951b
commit 5a960b37a4
3 changed files with 80 additions and 0 deletions

View File

@ -0,0 +1,68 @@
- hosts: all
tasks:
- name: Ensure artifacts/images directory exists
file:
path: '{{ ansible_user_dir }}/images'
state: directory
- name: Install docker
become: true
package:
name: docker.io
state: present
- name: Start docker
become: true
systemd:
name: docker.io
daemon_reload: true
- name: Run docker registry
become: true
shell: docker run -d --net=host --restart=always -v /opt/trove_registry/:/var/lib/registry --name registry registry:2
- name: Pull and push trove datastore images
become: true
shell: docker pull {{ item }} && docker tag {{item}} 127.0.0.1:5000/trove-datastores/{{ item }} && \
docker push 127.0.0.1:5000/trove-datastores/{{ item }}
loop:
- "mysql:5.7"
- "mysql:8.0"
- "mariadb:10.4"
- "postgres:12"
- name: Build mysql 5.7 backup image
become: true
shell: docker build -t 127.0.0.1:5000/trove-datastores/db-backup-mysql5.7:1.1.0 .
args:
chdir: "{{ ansible_user_dir }}/src/opendev.org/openstack/trove/backup"
- name: Build mysql 8.0 backup image
become: true
shell: sed -i s/mysql5.7/mysql8.0/ Dockerfile && \
docker build -t 127.0.0.1:5000/trove-datastores/db-backup-mysql8.0:1.1.0 .
args:
chdir: "{{ ansible_user_dir }}/src/opendev.org/openstack/trove/backup"
- name: Build mariadb backup image
become: true
shell: sed -i s/mysql8.0/mariadb/ Dockerfile && \
docker build -t 127.0.0.1:5000/trove-datastores/db-backup-mariadb:1.1.0 .
args:
chdir: "{{ ansible_user_dir }}/src/opendev.org/openstack/trove/backup"
- name: Build postgresql backup image
become: true
shell: sed -i s/mariadb/postgresql/ Dockerfile && \
docker build -t 127.0.0.1:5000/trove-datastores/db-backup-postgresql:1.1.2 .
args:
chdir: "{{ ansible_user_dir }}/src/opendev.org/openstack/trove/backup"
- name: Push the backup images
become: true
shell: docker push 127.0.0.1:5000/trove-datastores/db-backup-{{item}}
loop:
- "mariadb:1.1.0"
- "postgresql:1.1.2"
- name: Push mysql backup images
become: true
shell: docker push 127.0.0.1:5000/trove-datastores/db-backup-mysql{{ item }}:1.1.0
loop:
- "5.7"
- "8.0"
- name: Compress the docker registry files
become: true
archive:
path: "/opt/trove_registry/"
dest: '{{ ansible_user_dir }}/images/trove-datastore-registry-master.tar.gz'

View File

@ -477,3 +477,14 @@
branch: master branch: master
dev_mode: true dev_mode: true
image_suffix: "-dev" image_suffix: "-dev"
- job:
name: publish-trove-datastore-images
description: |
Build and publish trove datastore docker images to
tarballs.openstack.org.
run: playbooks/image-build/docker-registry.yaml
post-run: playbooks/image-build/post.yaml
nodeset: trove-ubuntu-focal-single
required-projects:
- openstack/trove

View File

@ -43,3 +43,4 @@
jobs: jobs:
- publish-trove-guest-image-ubuntu-focal - publish-trove-guest-image-ubuntu-focal
- publish-trove-guest-image-ubuntu-focal-dev - publish-trove-guest-image-ubuntu-focal-dev
- publish-trove-datastore-images