-
Notifications
You must be signed in to change notification settings - Fork 43
SANDBOX-1561 | feature: Makefile targets to build the operator in debug mode #720
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
Closed
MikelAlejoBR
wants to merge
2
commits into
codeready-toolchain:master
from
MikelAlejoBR:SANDBOX-1561-debug-sandbox-resources
+143
−1
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| # Compile Delve in an intermediate step. | ||
| FROM registry.access.redhat.com/ubi8/ubi:latest AS delve-builder | ||
|
|
||
| # The Golang version must be provided as a build arguments, which will ensure | ||
| # that Delve gets built with the same version the operator's binary gets built | ||
| # with, to avoid any discrepancies. | ||
| ARG GOLANG_VERSION | ||
|
|
||
| # Install Tar to be able to extract Golang. | ||
| RUN yum install --assumeyes \ | ||
| tar \ | ||
| && yum clean all | ||
|
|
||
| # Download and extract Golang. | ||
| RUN curl --location --output "${GOLANG_VERSION}.linux-amd64.tar.gz" "https://go.dev/dl/${GOLANG_VERSION}.linux-amd64.tar.gz" \ | ||
| && tar --directory /usr/local --extract --file "${GOLANG_VERSION}.linux-amd64.tar.gz" \ | ||
| && rm --force "${GOLANG_VERSION}.linux-amd64.tar.gz" | ||
|
|
||
| # Put Golang in the path so that we can Delve with it. | ||
| ENV PATH=$PATH:/usr/local/go/bin | ||
|
|
||
| # Build Delve and leave it in a temporary directory. | ||
| RUN GOBIN=/tmp/bin go install github.com/go-delve/delve/cmd/dlv@latest | ||
|
|
||
| # Build the operator as normal. | ||
| FROM registry.access.redhat.com/ubi8/ubi-minimal:latest | ||
|
|
||
| LABEL maintainer = "KubeSaw <devsandbox@redhat.com>" | ||
| LABEL author = "KubeSaw <devsandbox@redhat.com>" | ||
|
|
||
| # Ensure that the "DEBUG_MODE" is enabled so that the binary executes with | ||
| # Delve. | ||
| ENV DEBUG_MODE=true \ | ||
| OPERATOR=/usr/local/bin/member-operator \ | ||
| USER_UID=1001 \ | ||
| USER_NAME=member-operator \ | ||
| LANG=en_US.utf8 | ||
|
|
||
| # Install the operator binary in the image. | ||
| COPY build/_output/bin/member-operator ${OPERATOR} | ||
|
|
||
| COPY build/bin /usr/local/bin | ||
| RUN /usr/local/bin/user_setup | ||
|
|
||
| # Copy Delve to the image so that we can execute the operator with it. | ||
| COPY --from=delve-builder /tmp/bin/dlv /usr/local/bin/dlv | ||
|
|
||
| ENTRYPOINT ["/usr/local/bin/entrypoint"] | ||
|
|
||
| # Expose the debugger's port. | ||
| EXPOSE 50000 | ||
|
|
||
| USER ${USER_UID} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| # Compile Delve in an intermediate step. | ||
| FROM registry.access.redhat.com/ubi8/ubi:latest AS delve-builder | ||
|
|
||
| # The Golang version must be provided as a build arguments, which will ensure | ||
| # that Delve gets built with the same version the operator's binary gets built | ||
| # with, to avoid any discrepancies. | ||
| ARG GOLANG_VERSION | ||
|
|
||
| # Install Tar to be able to extract Golang. | ||
| RUN yum install --assumeyes \ | ||
| tar \ | ||
| && yum clean all | ||
|
|
||
| # Download and extract Golang. | ||
| RUN curl --location --output "${GOLANG_VERSION}.linux-amd64.tar.gz" "https://go.dev/dl/${GOLANG_VERSION}.linux-amd64.tar.gz" \ | ||
| && tar --directory /usr/local --extract --file "${GOLANG_VERSION}.linux-amd64.tar.gz" \ | ||
| && rm --force "${GOLANG_VERSION}.linux-amd64.tar.gz" | ||
|
|
||
| # Put Golang in the path so that we can Delve with it. | ||
| ENV PATH=$PATH:/usr/local/go/bin | ||
|
|
||
| # Build Delve and leave it in a temporary directory. | ||
| RUN GOBIN=/tmp/bin go install github.com/go-delve/delve/cmd/dlv@latest | ||
MikelAlejoBR marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # Build the operator as normal. | ||
| FROM registry.access.redhat.com/ubi8/ubi-minimal:latest | ||
|
|
||
| LABEL maintainer = "KubeSaw <devsandbox@redhat.com>" | ||
| LABEL author = "KubeSaw <devsandbox@redhat.com>" | ||
|
|
||
| # Ensure that the "DEBUG_MODE" is enabled so that the binary executes with | ||
| # Delve. | ||
| ENV DEBUG_MODE=true \ | ||
| WEBHOOK=/usr/local/bin/member-operator-webhook \ | ||
| USER_UID=1001 \ | ||
| USER_NAME=member-operator-webhook \ | ||
| LANG=en_US.utf8 | ||
|
|
||
| # Install the operator binary in the image. | ||
| COPY build/_output/bin/member-operator-webhook ${WEBHOOK} | ||
|
|
||
| COPY build/bin /usr/local/bin | ||
| RUN /usr/local/bin/user_setup | ||
|
|
||
| # Copy Delve to the image so that we can execute the operator with it. | ||
| COPY --from=delve-builder /tmp/bin/dlv /usr/local/bin/dlv | ||
|
|
||
| ENTRYPOINT ["/usr/local/bin/entrypoint"] | ||
|
|
||
| # Expose the debugger's port. | ||
| EXPOSE 50000 | ||
|
|
||
| USER ${USER_UID} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.