Skip to content
Open
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
28 changes: 15 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ PROJECT_VERSION ?= v1.4.0
TOP_DIR = $(PWD)
GOFLAGS := "-mod=mod"
GIT_COMMIT ?= $(shell git rev-parse --short HEAD)
CONTAINER_TOOL ?= docker
DOCKER_REGISTRY ?= docker.io/rocm
IMAGE_NAME ?= gpu-operator
IMAGE_TAG_BASE ?= $(DOCKER_REGISTRY)/$(IMAGE_NAME)
Expand Down Expand Up @@ -112,7 +113,8 @@ ENVTEST_K8S_VERSION = 1.23
# Options are set to exit when a recipe line exits non-zero or a piped command fails.
SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec
DOCKER_GID := $(shell stat -c '%g' /var/run/docker.sock)
DOCKER_SOCKET_FILE ?= /var/run/docker.sock
DOCKER_GID := $(shell stat -c '%g' $(DOCKER_SOCKET_FILE))
USER_UID := $(shell id -u)
USER_GID := $(shell id -g)
DOCKER_BUILDER_TAG := v1.2
Expand All @@ -134,7 +136,7 @@ HTML_DIR := $(BUILD_DIR)/html
.PHONY: default
default: docker-build-env ## Quick start to build everything from docker shell container.
@echo "Starting a shell in the Docker build container..."
@docker run --rm -it --privileged \
@$(CONTAINER_TOOL) run --rm -it --privileged \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @LaVLaS in the Makefile we prepared the docker/shell container to help developers quickly build all the artifacts of the project. With docker we prepared all the necessary changes to make the build within the shell container.

  1. I tried your PR, after witching to podman, it looks like podman is always directly changing the files ownership and permission on the host machine, can you take a look ?

  2. can you check and make sure the default target CONTAINER_TOOL=podman make could go through with this PR ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I'll take a look at the permissions issue but since the Dockerfile.build file is attempting to run docker in docker, I would recommend something like Distrobox for a containerized development & build workflow

--network host \
--name gpu-operator-build \
-e "USER_NAME=$(shell whoami)" \
Expand All @@ -143,23 +145,23 @@ default: docker-build-env ## Quick start to build everything from docker shell c
-v $(CURDIR):/gpu-operator \
-v $(CURDIR):/home/$(shell whoami)/go/src/github.com/ROCm/gpu-operator \
-v $(HOME)/.ssh:/home/$(shell whoami)/.ssh \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $(DOCKER_SOCKET_FILE):/var/run/docker.sock \
-w $(CONTAINER_WORKDIR) \
$(DOCKER_BUILDER_IMAGE) \
'bash -ic "source ~/.bashrc && cd /gpu-operator && git config --global --add safe.directory /gpu-operator && make all && GOFLAGS=-mod=mod go run tools/build/copyright/main.go && make fmt"'

.PHONY: docker/shell
docker/shell: docker-build-env ## Bring up and attach to a container that has dev environment configured.
@echo "Starting a shell in the Docker build container..."
@docker run --rm -it --privileged \
@$(CONTAINER_TOOL) run --rm -it --privileged \
--name gpu-operator-build \
-e "USER_NAME=$(shell whoami)" \
-e "USER_UID=$(shell id -u)" \
-e "USER_GID=$(shell id -g)" \
-v $(CURDIR):/gpu-operator \
-v $(CURDIR):/home/$(shell whoami)/go/src/github.com/ROCm/gpu-operator \
-v $(HOME)/.ssh:/home/$(shell whoami)/.ssh \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $(DOCKER_SOCKET_FILE):/var/run/docker.sock \
-w $(CONTAINER_WORKDIR) \
$(DOCKER_BUILDER_IMAGE) \
"cd /gpu-operator && git config --global --add safe.directory /gpu-operator && bash"
Expand Down Expand Up @@ -281,27 +283,27 @@ manager: $(shell find -name "*.go") go.mod go.sum ## Build manager binary.

.PHONY: docker-build
docker-build: ## Build docker image with the manager.
DOCKER_BUILDKIT=1 docker build -t $(IMG) --label HOURLY_TAG=$(HOURLY_TAG_LABEL) --build-arg TARGET=manager --build-arg GOLANG_BASE_IMG=$(GOLANG_BASE_IMG) .
DOCKER_BUILDKIT=1 $(CONTAINER_TOOL) build -t $(IMG) --label HOURLY_TAG=$(HOURLY_TAG_LABEL) --build-arg TARGET=manager --build-arg GOLANG_BASE_IMG=$(GOLANG_BASE_IMG) .

.PHONY: docker-push
docker-push: ## Push docker image with the manager.
docker push $(IMG)
$(CONTAINER_TOOL) push $(IMG)

.PHONY: docker-save
docker-save: ## Save the container image with the manager.
docker save $(IMG) | gzip > $(DOCKER_CONTAINER_IMG).tar.gz
$(CONTAINER_TOOL) save $(IMG) | gzip > $(DOCKER_CONTAINER_IMG).tar.gz

.PHONY: docker-build-env
docker-build-env: ## Build the docker shell container.
@echo "Building the Docker environment..."
@if [ -n $(INSECURE_REGISTRY) ]; then \
docker build \
$(CONTAINER_TOOL) build \
-t $(DOCKER_BUILDER_IMAGE) \
--build-arg BUILD_BASE_IMG=$(BUILD_BASE_IMG) \
--build-arg INSECURE_REGISTRY=$(INSECURE_REGISTRY) \
-f Dockerfile.build .; \
else \
docker build \
$(CONTAINER_TOOL) build \
-t $(DOCKER_BUILDER_IMAGE) \
--build-arg BUILD_BASE_IMG=$(BUILD_BASE_IMG) \
-f Dockerfile.build .; \
Expand Down Expand Up @@ -383,7 +385,7 @@ bundle-build: operator-sdk manifests kustomize ## OpenShift Build OLM bundle.
SOURCE_DIR=$(dir $(realpath $(lastword $(MAKEFILE_LIST)))) \
KUBECTL_CMD=${KUBECTL_CMD} ./hack/generate-bundle
${OPERATOR_SDK} bundle validate ./bundle
docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) .
$(CONTAINER_TOOL) build -f bundle.Dockerfile -t $(BUNDLE_IMG) .

.PHONY: dep-docs
dep-docs:
Expand Down Expand Up @@ -517,11 +519,11 @@ operator-sdk:

.PHONY: bundle-push
bundle-push:
docker push $(BUNDLE_IMG)
$(CONTAINER_TOOL) push $(BUNDLE_IMG)

.PHONY: bundle-save
bundle-save:
docker save $(BUNDLE_IMG) | gzip > $(IMAGE_NAME)-olm-bundle.tar.gz
$(CONTAINER_TOOL) save $(BUNDLE_IMG) | gzip > $(IMAGE_NAME)-olm-bundle.tar.gz

.PHONY: bundle-scorecard-test
bundle-scorecard-test:
Expand Down