-
Notifications
You must be signed in to change notification settings - Fork 1.8k
*: refactor Dockerfiles and Makefiles #4069
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
*: refactor Dockerfiles and Makefiles #4069
Conversation
f4e8d6f
to
37e61a3
Compare
their own Makefile, ex. image builds are in release/Makefile images/: move all Dockerfiles from hack/image to here, update references hack/: remove unnecessary wrapper scripts
37e61a3
to
9030482
Compare
The |
/hold |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My only real concern in the short term is the release
directory will probably cause a conflict and interact with the one in the downstream repo. This re-introduces the image/*
targets again which were removed in favor of -
target names. Technically I don't see anything wrong here so I'm okay with it.
echo "git and/or gpg are not configured to have default signing key $${default_key}"; \ | ||
exit 1; \ | ||
fi; \ | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: would be helpful to have the help target in the makefile, but I suspect we shouldn't be interacting with this file directly. I did find myself going into release
and running make help
to see what was in it :)
.PHONY: help
help: ## Show this help screen.
@echo 'Usage: make <OPTIONS> ... <TARGETS>'
@echo ''
@echo 'Available targets are:'
@echo ''
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z0-9_-]+:.*?##/ { printf " \033[36m%-25s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add this in #4034 since I'd like that Makefile to be called directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for the suggestion
Makefile
Outdated
$(e2e_targets):: test-e2e-setup image-build-scorecard-test | ||
$(e2e_targets):: test-e2e-setup image/scorecard-test | ||
|
||
test-e2e:: $(e2e_tests) ## Run e2e tests | ||
test-e2e-go:: image-build-custom-scorecard-tests ## Run Go e2e tests | ||
test-e2e-go:: image/custom-scorecard-tests ## Run Go e2e tests | ||
go test ./test/e2e-go -v -ginkgo.v | ||
test-e2e-ansible:: image-build-ansible ## Run Ansible e2e tests | ||
test-e2e-ansible:: image/ansible-operator ## Run Ansible e2e tests | ||
go test -count=1 ./internal/ansible/proxy/... | ||
go test ./test/e2e-ansible -v -ginkgo.v | ||
test-e2e-ansible-molecule:: image-build-ansible ## Run molecule-based Ansible e2e tests | ||
test-e2e-ansible-molecule:: image/ansible-operator ## Run molecule-based Ansible e2e tests | ||
./hack/tests/e2e-ansible-molecule.sh | ||
test-e2e-helm:: image-build-helm ## Run Helm e2e tests | ||
test-e2e-helm:: image/helm-operator ## Run Helm e2e tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah the only reason I re-added <type>/<pattern>
is for re-usability and de-cluttering, since Makefiles have great pattern matching/substitution functionality.
/hold cancel |
77bfc66
to
6c72670
Compare
KUBECONFIG= | ||
|
||
# install test binary | ||
COPY scorecard-test-kuttl ${TESTKUTTL} | ||
RUN echo "${USER_NAME}:x:${USER_UID}:0:${USER_NAME} user:${HOME}:/sbin/nologin" >> /etc/passwd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now we have all images following the same standard.
@@ -41,79 +45,39 @@ fix: ## Fixup files in the repo. | |||
|
|||
.PHONY: clean | |||
clean: ## Cleanup build artifacts and tool binaries. | |||
rm -rf $(BUILD_DIR) dist tools/bin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we not ignore the tools/ dir ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tools/bin
is already ignored. We can't ignore the whole tools/
directory since it contains scripts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple more comments and questions. Also, do you have a CI run in travis you can link that includes the deploy phases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am ok with these changes when passing in the CI.
Also, I added a few nits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I executed make release
from root dir and then, it created the bins into the dist/, however:
The checks made before was not made. E.g ensure that has a tag, do not allow uncommitted files.
$ make release
rm -rf build dist tools/bin
make -f release/Makefile GO_BUILD_ARGS='-gcflags "all=-trimpath=/Users/camilamacedo/go/src/github.com/operator-framework" -asmflags "all=-trimpath=/Users/camilamacedo/go/src/github.com/operator-framework" -ldflags " -X 'github.com/operator-framework/operator-sdk/internal/version.Version=v1.1.0+git' -X 'github.com/operator-framework/operator-sdk/internal/version.GitVersion=v1.1.0-7-gd7e63051' -X 'github.com/operator-framework/operator-sdk/internal/version.GitCommit=d7e63051b1dd74e0da8b88ab8de331e3e4af1348' -X 'github.com/operator-framework/operator-sdk/internal/version.KubernetesVersion=v1.18.8' " '
make[1]: Entering directory '/Users/camilamacedo/go/src/github.com/operator-framework/operator-sdk'
{ \
cmdpkg=$(echo operator-sdk-v1.1.0-7-gd7e63051-aarch64-linux-gnu | sed -E "s/(operator-sdk|ansible-operator|helm-operator).*/\1/"); \
go build -gcflags "all=-trimpath=/Users/camilamacedo/go/src/github.com/operator-framework" -asmflags "all=-trimpath=/Users/camilamacedo/go/src/github.com/operator-framework" -ldflags " -X github.com/operator-framework/operator-sdk/internal/version.Version=v1.1.0+git -X github.com/operator-framework/operator-sdk/internal/version.GitVersion=v1.1.0-7-gd7e63051 -X github.com/operator-framework/operator-sdk/internal/version.GitCommit=d7e63051b1dd74e0da8b88ab8de331e3e4af1348 -X github.com/operator-framework/operator-sdk/internal/version.KubernetesVersion=v1.18.8 " -o dist/operator-sdk-v1.1.0-7-gd7e63051-aarch64-linux-gnu ./cmd/$cmdpkg;
Also, if I go to cd release/ dir and run make release it is no working:
$ make release
{ \
cmdpkg=$(echo operator-sdk--aarch64-linux-gnu | sed -E "s/(operator-sdk|ansible-operator|helm-operator).*/\1/"); \
go build -o dist/operator-sdk--aarch64-linux-gnu ./cmd/$cmdpkg; \
}
stat /Users/camilamacedo/go/src/github.com/operator-framework/operator-sdk/release/cmd/operator-sdk: directory not found
make: *** [Makefile:89: dist/operator-sdk--aarch64-linux-gnu] Error 1
You need to run release.sh to get that functionality.
@estroz can correct me if I'm wrong, but that is not intended to work. Perhaps there's a way we can detect that someone called IMO, I wouldn't hold this PR up for that though. |
Correct. Often, nested Makefiles are not intended to be used standalone, and will error if you try to.
Good idea. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @joelanford,
You are right @estroz can correct me if I'm wrong, but that is not intended to work
. I do not think that the release is part of this one as well. I thought that make release calls that shell. However, I just checked that is not how it has been in the master too.
👍 Thank you for the explanations.
/lgtm for me this one.
name: Manifest lists | ||
script: | ||
- make image-push-ansible-multiarch image-push-helm-multiarch image-push-scorecard-test-multiarch image-push-scorecard-test-kuttl-multiarch image-push-sdk-multiarch | ||
script: make -f release/Makefile image-push-multiarch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I liked the cleanup in the Travis 👍
6c72670
to
d4839f3
Compare
New changes are detected. LGTM label has been removed. |
d4839f3
to
5957cd8
Compare
Example travis deploy (failing because the jobs can't push to operator-framework repos). |
Description of the change:
Motivation for the change: every make rule used for development purposes should exist in the top-level
Makefile
; every rule related to releases should exist inrelease/Makefile
to reduce clutter and separate concerns. Dockerfiles have been consolidated intoimages/
and slimmed down for similar reasons, including removing unnecessarydocker build
wrapper scripts. These images can be built by runningmake image/<image base name>
for development purposes.Nothing developer-facing has changed except for image build targets (
image-build-<base name>
->image/<base name>
) and multi-arch build targets (similarly renamed, and moved torelease/Makefile
).Relates to upcoming release automation work (see #3939, #4034).
Checklist
If the pull request includes user-facing changes, extra documentation is required:
changelog/fragments
(seechangelog/fragments/00-template.yaml
)website/content/en/docs