Skip to content

Commit

Permalink
Change docker buildx to not push by default
Browse files Browse the repository at this point in the history
Enable push via `DOCKER_BUILDX_PUSH = true`

prevent accidental push to default image registry
  • Loading branch information
TheRealHaoLiu committed Apr 1, 2024
1 parent 4b6f7e0 commit ad02f88
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 19 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/devel_images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,5 @@ jobs:
- name: Build and push AWX devel images
run: |
make ${{ matrix.build-targets.make-target }}
env:
DOCKER_BUILDX_PUSH: true
2 changes: 2 additions & 0 deletions .github/workflows/stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ jobs:
--build-arg OPERATOR_VERSION=${{ github.event.inputs.operator_version }}" \
IMG=ghcr.io/${{ github.repository_owner }}/awx-operator:${{ github.event.inputs.operator_version }} \
make docker-buildx
env:
DOCKER_BUILDX_PUSH: "true"

- name: Run test deployment with awx-operator
working-directory: awx-operator
Expand Down
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,12 @@ 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 defines the target platforms for the manager image be build to provide support to multiple
PLATFORMS ?= linux/amd64,linux/arm64 # linux/ppc64le,linux/s390x

# Set DOCKER_BUILDX_PUSH to "true" to push the image, set to any other value to skip pushing
DOCKER_BUILDX_PUSH ?= false

.PHONY: awx-link clean clean-tmp clean-venv requirements requirements_dev \
develop refresh adduser migrate dbchange \
receiver test test_unit test_coverage coverage_html \
Expand Down Expand Up @@ -602,8 +605,7 @@ docker-compose-build: Dockerfile.dev
docker-compose-buildx: Dockerfile.dev
- docker buildx create --name docker-compose-buildx
docker buildx use docker-compose-buildx
- docker buildx build \
--push \
- docker buildx build $(if $(filter true,$(DOCKER_BUILDX_PUSH)),--push,) \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--cache-from=$(DEV_DOCKER_TAG_BASE)/awx_devel:$(COMPOSE_TAG) \
--platform=$(PLATFORMS) \
Expand Down Expand Up @@ -674,8 +676,7 @@ awx-kube-build: Dockerfile
awx-kube-buildx: Dockerfile
- docker buildx create --name awx-kube-buildx
docker buildx use awx-kube-buildx
- docker buildx build \
--push \
- docker buildx build $(if $(filter true,$(DOCKER_BUILDX_PUSH)),--push,) \
--build-arg VERSION=$(VERSION) \
--build-arg SETUPTOOLS_SCM_PRETEND_VERSION=$(VERSION) \
--build-arg HEADLESS=$(HEADLESS) \
Expand Down Expand Up @@ -705,8 +706,7 @@ awx-kube-dev-build: Dockerfile.kube-dev
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 \
- docker buildx build $(if $(filter true,$(DOCKER_BUILDX_PUSH)),--push,) \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--cache-from=$(DEV_DOCKER_TAG_BASE)/awx_kube_devel:$(COMPOSE_TAG) \
--platform=$(PLATFORMS) \
Expand Down
17 changes: 5 additions & 12 deletions tools/ansible/roles/image_build/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,12 @@
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 }}"
shell: "make awx-kube-build"
environment:
DOCKER_BUILDKIT: 1
VERSION: "{{ awx_version }}"
HEADLESS: "{{ headless }}"
COMPOSE_TAG: "{{ awx_image_tag }}"

args:
chdir: "{{ playbook_dir }}/../../"

0 comments on commit ad02f88

Please sign in to comment.