diff options
author | Hao Liu <44379968+TheRealHaoLiu@users.noreply.github.com> | 2024-02-20 23:17:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-20 23:17:31 +0100 |
commit | 7caca60308616040f2b6b2a4f0bc079f9bba302f (patch) | |
tree | 9d68a26e3fbdb315b6e750d2a7d5a58eb61028e8 | |
parent | Add support for terraform credentials in awxkit (#14902) (diff) | |
download | awx-7caca60308616040f2b6b2a4f0bc079f9bba302f.tar.xz awx-7caca60308616040f2b6b2a4f0bc079f9bba302f.zip |
Multi-arch build for AWX images in ghcr.io (#14899)
build amd64 and ARM image for
- awx
- awx_devel
- awx_kube_devel
-rw-r--r-- | .github/workflows/devel_images.yml | 63 | ||||
-rw-r--r-- | Makefile | 64 | ||||
-rw-r--r-- | awx/ui_next/Makefile | 2 | ||||
-rw-r--r-- | tools/docker-compose/supervisor.conf | 1 |
4 files changed, 85 insertions, 45 deletions
diff --git a/.github/workflows/devel_images.yml b/.github/workflows/devel_images.yml index 7f8c791bc4..f99f578983 100644 --- a/.github/workflows/devel_images.yml +++ b/.github/workflows/devel_images.yml @@ -9,22 +9,43 @@ on: - release_* - feature_* jobs: - push: - if: endsWith(github.repository, '/awx') || startsWith(github.ref, 'refs/heads/release_') + push-development-images: runs-on: ubuntu-latest - timeout-minutes: 60 + timeout-minutes: 120 permissions: packages: write contents: read + strategy: + fail-fast: false + matrix: + build-targets: + - image-name: awx_devel + make-target: docker-compose-buildx + - image-name: awx_kube_devel + make-target: awx-kube-dev-buildx + - image-name: awx + make-target: awx-kube-buildx steps: + + - name: Skipping build of awx image for non-awx repository + run: | + echo "Skipping build of awx image for non-awx repository" + exit 0 + if: matrix.build-targets.image-name == 'awx' && !endsWith(github.repository, '/awx') + - uses: actions/checkout@v3 - - name: Get python version from Makefile - run: echo py_version=`make PYTHON_VERSION` >> $GITHUB_ENV + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 - - name: Set lower case owner name + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Set GITHUB_ENV variables run: | - echo "OWNER_LC=${OWNER,,}" >>${GITHUB_ENV} + echo "DEV_DOCKER_TAG_BASE=ghcr.io/${OWNER,,}" >> $GITHUB_ENV + echo "COMPOSE_TAG=${GITHUB_REF##*/}" >> $GITHUB_ENV + echo py_version=`make PYTHON_VERSION` >> $GITHUB_ENV env: OWNER: '${{ github.repository_owner }}' @@ -37,23 +58,19 @@ jobs: run: | echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin - - name: Pre-pull image to warm build cache - run: | - docker pull ghcr.io/${OWNER_LC}/awx_devel:${GITHUB_REF##*/} || : - docker pull ghcr.io/${OWNER_LC}/awx_kube_devel:${GITHUB_REF##*/} || : - docker pull ghcr.io/${OWNER_LC}/awx:${GITHUB_REF##*/} || : + - name: Setup node and npm + uses: actions/setup-node@v2 + with: + node-version: '16.13.1' + if: matrix.build-targets.image-name == 'awx' - - name: Build images + - name: Prebuild UI for awx image (to speed up build process) run: | - DEV_DOCKER_TAG_BASE=ghcr.io/${OWNER_LC} COMPOSE_TAG=${GITHUB_REF##*/} make docker-compose-build - DEV_DOCKER_TAG_BASE=ghcr.io/${OWNER_LC} COMPOSE_TAG=${GITHUB_REF##*/} make awx-kube-dev-build - DEV_DOCKER_TAG_BASE=ghcr.io/${OWNER_LC} COMPOSE_TAG=${GITHUB_REF##*/} make awx-kube-build + sudo apt-get install gettext + make ui-release + make ui-next + if: matrix.build-targets.image-name == 'awx' - - name: Push development images + - name: Build and push AWX devel images run: | - docker push ghcr.io/${OWNER_LC}/awx_devel:${GITHUB_REF##*/} - docker push ghcr.io/${OWNER_LC}/awx_kube_devel:${GITHUB_REF##*/} - - - name: Push AWX k8s image, only for upstream and feature branches - run: docker push ghcr.io/${OWNER_LC}/awx:${GITHUB_REF##*/} - if: endsWith(github.repository, '/awx') + make ${{ matrix.build-targets.make-target }} @@ -75,6 +75,9 @@ SDIST_TAR_FILE ?= $(SDIST_TAR_NAME).tar.gz I18N_FLAG_FILE = .i18n_built +## PLATFORMS defines the target platforms for the manager image be build to provide support to multiple +PLATFORMS ?= linux/amd64,linux/arm64 # linux/ppc64le,linux/s390x + .PHONY: awx-link clean clean-tmp clean-venv requirements requirements_dev \ develop refresh adduser migrate dbchange \ receiver test test_unit test_coverage coverage_html \ @@ -532,7 +535,7 @@ docker-compose-sources: .git/hooks/pre-commit -e enable_vault=$(VAULT) \ -e vault_tls=$(VAULT_TLS) \ -e enable_tacacs=$(TACACS) \ - $(EXTRA_SOURCES_ANSIBLE_OPTS) + $(EXTRA_SOURCES_ANSIBLE_OPTS) docker-compose: awx/projects docker-compose-sources ansible-galaxy install --ignore-certs -r tools/docker-compose/ansible/requirements.yml; @@ -586,28 +589,20 @@ docker-compose-build: Dockerfile.dev --build-arg BUILDKIT_INLINE_CACHE=1 \ --cache-from=$(DEV_DOCKER_TAG_BASE)/awx_devel:$(COMPOSE_TAG) . -# ## Build awx_devel image for docker compose development environment for multiple architectures -# docker-compose-buildx: Dockerfile.dev -# DOCKER_BUILDKIT=1 docker build \ -# -f Dockerfile.dev \ -# -t $(DEVEL_IMAGE_NAME) \ -# --build-arg BUILDKIT_INLINE_CACHE=1 \ -# --cache-from=$(DEV_DOCKER_TAG_BASE)/awx_devel:$(COMPOSE_TAG) . -## Build awx_devel image for docker compose development environment for multiple architectures -# PLATFORMS defines the target platforms for the manager image be build to provide support to multiple -# architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to: -# - able to use docker buildx . More info: https://docs.docker.com/build/buildx/ -# - have enable BuildKit, More info: https://docs.docker.com/develop/develop-images/build_enhancements/ -# - be able to push the image for your registry (i.e. if you do not inform a valid value via IMG=<myregistry/image:<tag>> than the export will fail) -# To properly provided solutions that supports more than one platform you should use this option. -PLATFORMS ?= linux/amd64,linux/arm64 # linux/ppc64le,linux/s390x .PHONY: docker-compose-buildx -docker-compose-buildx: Dockerfile.dev ## Build and push docker image for the manager for cross-platform support - - docker buildx create --name project-v3-builder - docker buildx use project-v3-builder - - docker buildx build --push $(BUILD_ARGS) --platform=$(PLATFORMS) --tag $(DEVEL_IMAGE_NAME) -f Dockerfile.dev . - - docker buildx rm project-v3-builder +## Build awx_devel image for docker compose development environment for multiple architectures +docker-compose-buildx: Dockerfile.dev + - docker buildx create --name docker-compose-buildx + docker buildx use docker-compose-buildx + - docker buildx build \ + --push \ + --build-arg BUILDKIT_INLINE_CACHE=1 \ + --cache-from=$(DEV_DOCKER_TAG_BASE)/awx_devel:$(COMPOSE_TAG) \ + --platform=$(PLATFORMS) \ + --tag $(DEVEL_IMAGE_NAME) \ + -f Dockerfile.dev . + - docker buildx rm docker-compose-buildx docker-clean: -$(foreach container_id,$(shell docker ps -f name=tools_awx -aq && docker ps -f name=tools_receptor -aq),docker stop $(container_id); docker rm -f $(container_id);) @@ -671,6 +666,21 @@ awx-kube-build: Dockerfile --build-arg HEADLESS=$(HEADLESS) \ -t $(DEV_DOCKER_TAG_BASE)/awx:$(COMPOSE_TAG) . +## Build multi-arch awx image for deployment on Kubernetes environment. +awx-kube-buildx: Dockerfile + - docker buildx create --name awx-kube-buildx + docker buildx use awx-kube-buildx + - docker buildx build \ + --push \ + --build-arg VERSION=$(VERSION) \ + --build-arg SETUPTOOLS_SCM_PRETEND_VERSION=$(VERSION) \ + --build-arg HEADLESS=$(HEADLESS) \ + --platform=$(PLATFORMS) \ + --tag $(DEV_DOCKER_TAG_BASE)/awx:$(COMPOSE_TAG) \ + -f Dockerfile . + - docker buildx rm awx-kube-buildx + + .PHONY: Dockerfile.kube-dev ## Generate Docker.kube-dev for awx_kube_devel image Dockerfile.kube-dev: tools/ansible/roles/dockerfile/templates/Dockerfile.j2 @@ -687,6 +697,18 @@ awx-kube-dev-build: Dockerfile.kube-dev --cache-from=$(DEV_DOCKER_TAG_BASE)/awx_kube_devel:$(COMPOSE_TAG) \ -t $(DEV_DOCKER_TAG_BASE)/awx_kube_devel:$(COMPOSE_TAG) . +## Build and push multi-arch awx_kube_devel image for development on local Kubernetes environment. +awx-kube-dev-buildx: Dockerfile.kube-dev + - docker buildx create --name awx-kube-dev-buildx + docker buildx use awx-kube-dev-buildx + - docker buildx build \ + --push \ + --build-arg BUILDKIT_INLINE_CACHE=1 \ + --cache-from=$(DEV_DOCKER_TAG_BASE)/awx_kube_devel:$(COMPOSE_TAG) \ + --platform=$(PLATFORMS) \ + --tag $(DEV_DOCKER_TAG_BASE)/awx_kube_devel:$(COMPOSE_TAG) \ + -f Dockerfile.kube-dev . + - docker buildx rm awx-kube-dev-buildx kind-dev-load: awx-kube-dev-build $(KIND_BIN) load docker-image $(DEV_DOCKER_TAG_BASE)/awx_kube_devel:$(COMPOSE_TAG) diff --git a/awx/ui_next/Makefile b/awx/ui_next/Makefile index c36b2d273c..db5a8d2d80 100644 --- a/awx/ui_next/Makefile +++ b/awx/ui_next/Makefile @@ -35,7 +35,7 @@ ui-next/src/build: $(UI_NEXT_DIR)/src/build/awx ## True target for ui-next/src/build. Build ui_next from source. $(UI_NEXT_DIR)/src/build/awx: $(UI_NEXT_DIR)/src $(UI_NEXT_DIR)/src/node_modules/webpack @echo "=== Building ui_next ===" - @cd $(UI_NEXT_DIR)/src && PRODUCT="$(PRODUCT)" PUBLIC_PATH=/static/awx/ npm run build:awx + @cd $(UI_NEXT_DIR)/src && PRODUCT="$(PRODUCT)" PUBLIC_PATH=/static/awx/ ROUTE_PREFIX=/ui_next npm run build:awx @mv $(UI_NEXT_DIR)/src/build/awx/index.html $(UI_NEXT_DIR)/src/build/awx/index_awx.html .PHONY: ui-next/src diff --git a/tools/docker-compose/supervisor.conf b/tools/docker-compose/supervisor.conf index ec3e32f9d1..9541b54531 100644 --- a/tools/docker-compose/supervisor.conf +++ b/tools/docker-compose/supervisor.conf @@ -96,6 +96,7 @@ stdout_logfile=/dev/stdout stdout_logfile_maxbytes=0 stderr_logfile=/dev/stderr stderr_logfile_maxbytes=0 + [program:awx-rsyslogd] command = rsyslogd -n -i /var/run/awx-rsyslog/rsyslog.pid -f /var/lib/awx/rsyslog/rsyslog.conf autorestart = true |