diff options
-rw-r--r-- | .github/workflows/ci.yml | 12 | ||||
-rw-r--r-- | .github/workflows/stage.yml | 92 | ||||
-rw-r--r-- | docs/build_awx_image.md | 6 | ||||
-rw-r--r-- | tools/ansible/build.yml | 25 | ||||
-rw-r--r-- | tools/ansible/roles/image_build/defaults/main.yml | 5 | ||||
-rw-r--r-- | tools/ansible/roles/image_build/tasks/main.yml | 30 | ||||
-rw-r--r-- | tools/ansible/roles/image_push/defaults/main.yml | 4 | ||||
-rw-r--r-- | tools/ansible/roles/image_push/tasks/main.yml | 22 |
8 files changed, 65 insertions, 131 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b487c73e6c..e2d205a1dd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -94,11 +94,11 @@ jobs: - name: Build AWX image working-directory: awx run: | - ansible-playbook -v tools/ansible/build.yml \ - -e headless=yes \ - -e awx_image=awx \ - -e awx_image_tag=ci \ - -e ansible_python_interpreter=$(which python3) + VERSION=`make version-for-buildyml` make awx-kube-build + env: + COMPOSE_TAG: ci + DEV_DOCKER_TAG_BASE: local + HEADLESS: yes - name: Run test deployment with awx-operator working-directory: awx-operator @@ -109,7 +109,7 @@ jobs: make kustomize KUSTOMIZE_PATH=$(readlink -f bin/kustomize) molecule -v test -s kind -- --skip-tags=replicas env: - AWX_TEST_IMAGE: awx + AWX_TEST_IMAGE: local/awx AWX_TEST_VERSION: ci collection-sanity: diff --git a/.github/workflows/stage.yml b/.github/workflows/stage.yml index 26eedf7747..ddf4d9c6ee 100644 --- a/.github/workflows/stage.yml +++ b/.github/workflows/stage.yml @@ -49,13 +49,11 @@ jobs: with: path: awx - - name: Get python version from Makefile - run: echo py_version=`make PYTHON_VERSION` >> $GITHUB_ENV - - - name: Install python ${{ env.py_version }} - uses: actions/setup-python@v4 + - name: Checkout awx-operator + uses: actions/checkout@v3 with: - python-version: ${{ env.py_version }} + repository: ${{ github.repository_owner }}/awx-operator + path: awx-operator - name: Checkout awx-logos uses: actions/checkout@v3 @@ -63,57 +61,85 @@ jobs: repository: ansible/awx-logos path: awx-logos - - name: Checkout awx-operator - uses: actions/checkout@v3 + - name: Get python version from Makefile + working-directory: awx + run: echo py_version=`make PYTHON_VERSION` >> $GITHUB_ENV + + - name: Install python ${{ env.py_version }} + uses: actions/setup-python@v4 with: - repository: ${{ github.repository_owner }}/awx-operator - path: awx-operator + python-version: ${{ env.py_version }} - name: Install playbook dependencies run: | python3 -m pip install docker - - name: Build and stage AWX - working-directory: awx - run: | - ansible-playbook -v tools/ansible/build.yml \ - -e registry=ghcr.io \ - -e registry_username=${{ github.actor }} \ - -e registry_password=${{ secrets.GITHUB_TOKEN }} \ - -e awx_image=${{ github.repository }} \ - -e awx_version=${{ github.event.inputs.version }} \ - -e ansible_python_interpreter=$(which python3) \ - -e push=yes \ - -e awx_official=yes - - name: Log into registry ghcr.io - uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Log into registry quay.io - uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 + - name: Copy logos for inclusion in sdist for official build + working-directory: awx + run: | + cp ../awx-logos/awx/ui/client/assets/* awx/ui/public/static/media/ + + - name: Setup node and npm + uses: actions/setup-node@v2 with: - registry: quay.io - username: ${{ secrets.QUAY_USER }} - password: ${{ secrets.QUAY_TOKEN }} + node-version: '16.13.1' + + - name: Prebuild UI for awx image (to speed up build process) + working-directory: awx + run: | + sudo apt-get install gettext + make ui-release + make ui-next + + - name: Set build env variables + run: | + echo "DEV_DOCKER_TAG_BASE=ghcr.io/${OWNER,,}" >> $GITHUB_ENV + echo "COMPOSE_TAG=${{ github.event.inputs.version }}" >> $GITHUB_ENV + echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV + echo "AWX_TEST_VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV + echo "AWX_TEST_IMAGE=ghcr.io/${OWNER,,}/awx" >> $GITHUB_ENV + echo "AWX_EE_TEST_IMAGE=ghcr.io/${OWNER,,}/awx-ee:${{ github.event.inputs.version }}" >> $GITHUB_ENV + echo "AWX_OPERATOR_TEST_IMAGE=ghcr.io/${OWNER,,}/awx-operator:${{ github.event.inputs.operator_version }}" >> $GITHUB_ENV + env: + OWNER: ${{ github.repository_owner }} + + - name: Build and stage AWX + working-directory: awx + env: + DOCKER_BUILDX_PUSH: true + HEADLESS: false + PLATFORMS: linux/amd64,linux/arm64 + run: | + make awx-kube-buildx - name: tag awx-ee:latest with version input run: | docker buildx imagetools create \ quay.io/ansible/awx-ee:latest \ - --tag ghcr.io/${{ github.repository_owner }}/awx-ee:${{ github.event.inputs.version }} + --tag ${AWX_EE_TEST_IMAGE} - name: Stage awx-operator image working-directory: awx-operator run: | BUILD_ARGS="--build-arg DEFAULT_AWX_VERSION=${{ github.event.inputs.version}} \ --build-arg OPERATOR_VERSION=${{ github.event.inputs.operator_version }}" \ - IMG=ghcr.io/${{ github.repository_owner }}/awx-operator:${{ github.event.inputs.operator_version }} \ + IMG=${AWX_OPERATOR_TEST_IMAGE} \ make docker-buildx + - name: Pulling images for test deployment with awx-operator + # awx operator molecue test expect to kind load image and buildx exports image to registry and not local + run: | + docker pull ${AWX_OPERATOR_TEST_IMAGE} + docker pull ${AWX_EE_TEST_IMAGE} + docker pull ${AWX_TEST_IMAGE}:${AWX_TEST_VERSION} + - name: Run test deployment with awx-operator working-directory: awx-operator run: | @@ -122,10 +148,6 @@ jobs: sudo rm -f $(which kustomize) make kustomize KUSTOMIZE_PATH=$(readlink -f bin/kustomize) molecule test -s kind - env: - AWX_TEST_IMAGE: ${{ github.repository }} - AWX_TEST_VERSION: ${{ github.event.inputs.version }} - AWX_EE_TEST_IMAGE: ghcr.io/${{ github.repository_owner }}/awx-ee:${{ github.event.inputs.version }} - name: Create draft release for AWX working-directory: awx diff --git a/docs/build_awx_image.md b/docs/build_awx_image.md index c359f7e31e..f2a0b6c35e 100644 --- a/docs/build_awx_image.md +++ b/docs/build_awx_image.md @@ -2,12 +2,10 @@ ## Build & Push Image -To build a custom awx image to use with the awx-operator, use the `build_image` role: +To build a custom awx image to use with the awx-operator: ``` -$ ansible-playbook tools/ansible/build.yml \ - -e awx_image=registry.example.com/ansible/awx \ - -e awx_image_tag=test -v +make awx-kube-build ``` > Note: The development image (`make docker-compose-build`) will not work with the awx-operator, the UI is not built in that image, among other things (see Dockerfile.j2 for more info). diff --git a/tools/ansible/build.yml b/tools/ansible/build.yml deleted file mode 100644 index 9270d69f58..0000000000 --- a/tools/ansible/build.yml +++ /dev/null @@ -1,25 +0,0 @@ ---- -- name: Build AWX Docker Images - hosts: localhost - gather_facts: true - tasks: - - name: Get version from SCM if not explicitly provided - command: make version-for-buildyml - args: - chdir: '../../' - register: scm_version - failed_when: not scm_version.stdout - when: awx_version is not defined - - - name: Set awx_version - set_fact: - awx_version: "{{ scm_version.stdout }}" - when: awx_version is not defined - - - include_role: - name: dockerfile - - include_role: - name: image_build - - include_role: - name: image_push - when: push | default(false) | bool diff --git a/tools/ansible/roles/image_build/defaults/main.yml b/tools/ansible/roles/image_build/defaults/main.yml deleted file mode 100644 index 328f78cc1d..0000000000 --- a/tools/ansible/roles/image_build/defaults/main.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -awx_image: ansible/awx -awx_image_tag: "{{ awx_version }}" -dockerfile_name: 'Dockerfile' -headless: no diff --git a/tools/ansible/roles/image_build/tasks/main.yml b/tools/ansible/roles/image_build/tasks/main.yml deleted file mode 100644 index 9a1fb10c1b..0000000000 --- a/tools/ansible/roles/image_build/tasks/main.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- -- name: Verify awx-logos directory exists for official install - stat: - path: "../../../awx-logos" - register: logosdir - failed_when: logosdir.stat.isdir is not defined or not logosdir.stat.isdir - when: awx_official|default(false)|bool - -- name: Copy logos for inclusion in sdist - copy: - src: "../../../awx-logos/awx/ui/client/assets/" - dest: "../../awx/ui/public/static/media/" - when: awx_official|default(false)|bool - -- set_fact: - command_to_run: | - docker build -t {{ awx_image }}:{{ awx_image_tag }} \ - -f {{ dockerfile_name }} \ - --build-arg VERSION={{ awx_version }} \ - --build-arg SETUPTOOLS_SCM_PRETEND_VERSION={{ awx_version }} \ - --build-arg HEADLESS={{ headless }} \ - . - -# Calling Docker directly because docker-py doesnt support BuildKit -- name: Build AWX image - shell: "{{ command_to_run }}" - environment: - DOCKER_BUILDKIT: 1 - args: - chdir: "{{ playbook_dir }}/../../" diff --git a/tools/ansible/roles/image_push/defaults/main.yml b/tools/ansible/roles/image_push/defaults/main.yml deleted file mode 100644 index 58bea4bcf8..0000000000 --- a/tools/ansible/roles/image_push/defaults/main.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -registry: quay.io -awx_image: ansible/awx -awx_image_tag: "{{ awx_version }}" diff --git a/tools/ansible/roles/image_push/tasks/main.yml b/tools/ansible/roles/image_push/tasks/main.yml deleted file mode 100644 index 28e671f676..0000000000 --- a/tools/ansible/roles/image_push/tasks/main.yml +++ /dev/null @@ -1,22 +0,0 @@ ---- -- name: Authenticate with Docker registry if registry password given - docker_login: - registry: "{{ registry }}" - username: "{{ registry_username }}" - password: "{{ registry_password }}" - reauthorize: true - when: - - registry is defined - - registry_username is defined - - registry_password is defined - -- name: Tag and Push Container Images - docker_image: - name: "{{ awx_image }}:{{ awx_image_tag }}" - repository: "{{ registry }}/{{ awx_image }}:{{ item }}" - force_tag: yes - push: true - source: local - with_items: - - "latest" - - "{{ awx_image_tag }}" |