Skip to content

Commit

Permalink
add debug image
Browse files Browse the repository at this point in the history
  • Loading branch information
bdevcich committed Sep 16, 2024
1 parent 0fa90f2 commit f1f06ab
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 4 deletions.
91 changes: 90 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ env:
DO_TEST: true

jobs:
build:
production:
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -95,6 +95,95 @@ jobs:
uses: docker/build-push-action@v3
with:
push: true
target: production
tags: ${{ steps.meta.outputs.tags }}

debug:
runs-on: ubuntu-latest

steps:
- name: "Build context"
run: |
echo "ref is ${{ github.ref }}"
echo "ref_type is ${{ github.ref_type }}"
- name: "Checkout repository"
id: checkout_repo
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}

- name: "Lowercase repository name for docker build"
id: lowercase-repository-name
run: echo "REPO_NAME=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV

- name: "Set tags for main/master"
id: set_tags
run: |
echo "VERSION_TAG=$(./git-version-gen | grep -v UNKNOWN)" >> ${GITHUB_ENV}
echo "TEST_TAG=$(git rev-parse HEAD)-test" >> ${GITHUB_ENV}
echo "SHA_TAG=$(git rev-parse HEAD)" >> ${GITHUB_ENV}
echo "${GITHUB_ENV}:"
cat ${GITHUB_ENV}
shell: bash

- name: "Verify auto-generated files"
run: |
make manifests generate
if [[ $(git status -s | wc -l) -gt 0 ]]; then \
git status; exit 1; \
fi
- name: "Docker metadata"
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/${{ env.REPO_NAME }}-debug
tags: |
# For merge to master branch, tag example: 'master'
type=ref,event=branch
# For PR event, tag example: 'pr-3'
type=ref,event=pr
# For PR event or merge event, tag example: 1.0.1.12-5667
type=raw,value=${{ env.VERSION_TAG }}
# For PR event or merge, tag example: 566769e04d2436cf5f42ae4f46092c7dff6e668e
type=raw,value=${{ env.SHA_TAG }}
# For push to semver tag, tag example: 1.0.2
# This also sets 'latest'.
type=semver,pattern={{version}}
# For push to semver tag, tag example: 1.0
type=semver,pattern={{major}}.{{minor}}
- name: "Docker login"
id: docker_login
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: "Build the test Docker image"
id: docker_build_test_target
if: ${{ env.DO_TEST == 'true' }}
uses: docker/build-push-action@v2
with:
push: false
target: ${{ env.TEST_TARGET }}
tags: ${{ env.REPO_NAME }}:${{ env.TEST_TAG }}

- name: "Run the Docker image unit tests"
id: docker_test
if: ${{ env.DO_TEST == 'true' }}
run: docker run ${{ env.REPO_NAME }}:${{ env.TEST_TAG }}

- name: "Build the debug Docker image"
id: docker_build
uses: docker/build-push-action@v3
with:
push: true
target: debug
tags: ${{ steps.meta.outputs.tags }}

create_release:
Expand Down
22 changes: 21 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ ENV CGO_ENABLED=0
ENTRYPOINT [ "make", "test" ]

###############################################################################
FROM $NNFMFU_TAG_BASE:$NNFMFU_VERSION
FROM $NNFMFU_TAG_BASE:$NNFMFU_VERSION AS production

# The following lines are from the mpiFileUtils (nnf-mfu) Dockerfile;
# do not change them unless you know what it is you are doing
Expand All @@ -82,3 +82,23 @@ ARG NNFMFU_TAG_BASE
ARG NNFMFU_VERSION
LABEL nnf-mfu="$NNFMFU_TAG_BASE:$NNFMFU_VERSION"

###############################################################################
# Use the nnf-mfu-debug image as a base
FROM $NNFMFU_TAG_BASE-debug:$NNFMFU_VERSION AS debug

# The following lines are from the mpiFileUtils (nnf-mfu) Dockerfile;
# do not change them unless you know what it is you are doing
RUN sed -i "s/[ #]\(.*StrictHostKeyChecking \).*/ \1no/g" /etc/ssh/ssh_config \
&& echo " UserKnownHostsFile /dev/null" >> /etc/ssh/ssh_config

# Copy the executable and execute
WORKDIR /
COPY --from=builder /workspace/manager .

ENTRYPOINT ["/manager"]

# Make it easy to figure out which nnf-mfu was used.
# docker inspect --format='{{json .Config.Labels}}' image:tag
ARG NNFMFU_TAG_BASE
ARG NNFMFU_VERSION
LABEL nnf-mfu="$NNFMFU_TAG_BASE-debug:$NNFMFU_VERSION"
23 changes: 21 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)
# For example, running 'make bundle-build bundle-push catalog-build catalog-push' will build and push both
# cray.hpe.com/nnf-dm-bundle:$VERSION and cray.hpe.com/nnf-dm-catalog:$VERSION.
IMAGE_TAG_BASE ?= ghcr.io/nearnodeflash/nnf-dm
IMAGE_TARGET ?= production

# The NNF-MFU container image to use in NNFContainerProfile resources.
NNFMFU_TAG_BASE ?= ghcr.io/nearnodeflash/nnf-mfu
Expand Down Expand Up @@ -163,13 +164,22 @@ run: manifests generate fmt vet ## Run a controller from your host.
.PHONY: docker-build
docker-build: VERSION ?= $(shell cat .version)
docker-build: .version ## Build docker image with the manager.
${CONTAINER_TOOL} build -t $(IMAGE_TAG_BASE):$(VERSION) $(CONTAINER_BUILDARGS) .
${CONTAINER_TOOL} build --target $(IMAGE_TARGET) -t $(IMAGE_TAG_BASE):$(VERSION) $(CONTAINER_BUILDARGS) .

.PHONY: docker-build-debug
docker-build-debug: IMAGE_TAG_BASE := $(IMAGE_TAG_BASE)-debug
docker-build-debug: IMAGE_TARGET := debug
docker-build-debug: docker-build

.PHONY: docker-push
docker-push: VERSION ?= $(shell cat .version)
docker-push: .version ## Push docker image with the manager.
${CONTAINER_TOOL} push $(IMAGE_TAG_BASE):$(VERSION)

.PHONY: docker-push-debug
docker-push-debug: IMAGE_TAG_BASE := $(IMAGE_TAG_BASE)-debug
docker-push-debug: docker-push

# PLATFORMS defines the target platforms for the manager image be built to provide support to multiple
# architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to:
# - be able to use docker buildx. More info: https://docs.docker.com/build/buildx/
Expand All @@ -184,10 +194,15 @@ docker-buildx: ## Build and push docker image for the manager for cross-platform
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
- $(CONTAINER_TOOL) buildx create --name project-v3-builder
$(CONTAINER_TOOL) buildx use project-v3-builder
- $(CONTAINER_TOOL) buildx build --push --platform=$(PLATFORMS) --tag $(IMAGE_TAG_BASE):$(VERSION) -f Dockerfile.cross .
- $(CONTAINER_TOOL) buildx build --push --platform=$(PLATFORMS) --target $(IMAGE_TARGET) --tag $(IMAGE_TAG_BASE):$(VERSION) -f Dockerfile.cross .
- $(CONTAINER_TOOL) buildx rm project-v3-builder
rm Dockerfile.cross

.PHONY: docker-buildx-debug
docker-buildx-debug: IMAGE_TAG_BASE := $(IMAGE_TAG_BASE)-debug
docker-buildx-debug: IMAGE_TARGET := debug
docker-buildx-debug: docker-buildx

kind-push: VERSION ?= $(shell cat .version)
kind-push: .version ## Push docker image to kind
# Nnf-dm is used on all nodes. It's on the management node for the
Expand All @@ -197,6 +212,10 @@ kind-push: .version ## Push docker image to kind
${CONTAINER_TOOL} pull gcr.io/kubebuilder/kube-rbac-proxy:v0.13.0
kind load docker-image gcr.io/kubebuilder/kube-rbac-proxy:v0.13.0

kind-push-debug: VERSION ?= $(shell cat .version)
kind-push-debug: IMAGE_TAG_BASE := $(IMAGE_TAG_BASE)-debug
kind-push-debug: kind-push

minikube-push: VERSION ?= $(shell cat .version)
minikube-push: .version
minikube image load $(IMAGE_TAG_BASE):$(VERSION)
Expand Down

0 comments on commit f1f06ab

Please sign in to comment.