Skip to content
This repository has been archived by the owner on Aug 19, 2024. It is now read-only.

chore: adjust makefile to be able to use in GH action (#73 ) #123

Merged
merged 6 commits into from
Jan 10, 2024

Conversation

nickboldt
Copy link
Member

What does this PR do?

chore: adjust makefile to be able to use in GH action (#73 )

Signed-off-by: RHDH Build (rhdh-bot) rhdh-bot@redhat.com

Screenshot/screencast of this PR

N/A

What issues does this PR fix or reference?

N/A (or see commit message above for issue number)

How to test this PR?

N/A

PR Checklist

As the author of this Pull Request I made sure that:

Reviewers

Reviewers, please comment how you tested the PR when approving it.

@nickboldt
Copy link
Member Author

@rm3l do we need the pr.yaml to run on BOTH docker and podman? I would think we would be good enough with just podman, until such time as we want multi-arch builds upstream with docker buildx. For now, we should be fine with the simpler podman build approach, which means the local builds I do in Fedora with the makefile are the same as those done in GH action.

Do you use docker locally? If so we could switch to using docker in the GH actions...

@nickboldt
Copy link
Member Author

nickboldt commented Jan 8, 2024

Tested locally with:

export CONTAINER_ENGINE=podman 
export VERSION=pr-1234-f00cafebabe
CONTAINER_ENGINE=${CONTAINER_ENGINE} VERSION=0.0.1-${VERSION} make release-build release-push

Result is this diff:

diff --git a/bundle/manifests/backstage-operator.clusterserviceversion.yaml b/bundle/manifests/backstage-operator.clusterserviceversion.yaml
index bde72d8..652962e 100644
--- a/bundle/manifests/backstage-operator.clusterserviceversion.yaml
+++ b/bundle/manifests/backstage-operator.clusterserviceversion.yaml
@@ -21,10 +21,10 @@ metadata:
         }
       ]
     capabilities: Basic Install
     operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
-  name: backstage-operator.v0.0.1
+  name: backstage-operator.v0.0.1-pr-1234-f00cafebabe
   namespace: placeholder
 spec:
   apiservicedefinitions: {}
@@ -206,7 +206,7 @@ spec:
                   value: quay.io/fedora/postgresql-15:latest
                 - name: RELATED_IMAGE_backstage
                   value: quay.io/janus-idp/backstage-showcase:next
-                image: quay.io/janus/operator:next
+                image: quay.io/janus/operator:0.0.1-pr-1234-f00cafebabe
                 livenessProbe:
                   httpGet:
                     path: /healthz
@@ -309,4 +309,4 @@ spec:
     name: postgresql
   - image: quay.io/janus-idp/backstage-showcase:next
     name: backstage
-  version: 0.0.1
+  version: 0.0.1-pr-1234-f00cafebabe
 
diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml
index 027d0ce..413bbc1 100644
--- a/config/manager/kustomization.yaml
+++ b/config/manager/kustomization.yaml
@@ -5,7 +5,7 @@ kind: Kustomization
 images:
 - name: controller
   newName: quay.io/janus/operator
-  newTag: v0.0.1
+  newTag: 0.0.1-pr-1234-f00cafebabe
 
 generatorOptions:
   disableNameSuffixHash: true

Signed-off-by: RHDH Build (rhdh-bot) <rhdh-bot@redhat.com>

also make sure podman is installed

Signed-off-by: RHDH Build (rhdh-bot) <rhdh-bot@redhat.com>

add linting to the PR check, so we can basically remove py.yaml

Signed-off-by: RHDH Build (rhdh-bot) <rhdh-bot@redhat.com>

update matrix PR check job so it'll work, if we still want it (but I'd argue we can delete it)

Signed-off-by: RHDH Build (rhdh-bot) <rhdh-bot@redhat.com>

rename actions since they don't necessarily need docker to build container

Signed-off-by: RHDH Build (rhdh-bot) <rhdh-bot@redhat.com>
…and use that in pr and next tags, so we have separation between releases; this will require that we update the Makefile after every release (eg., 0.0.1, 0.0.2, 0.0.3)

Signed-off-by: RHDH Build (rhdh-bot) <rhdh-bot@redhat.com>

tweak comment: also pushing a :next tag

Signed-off-by: RHDH Build (rhdh-bot) <rhdh-bot@redhat.com>
@nickboldt nickboldt changed the title chore: adjust makefile to be able to use in... chore: adjust makefile to be able to use in GH action (#73 ) Jan 9, 2024
Makefile Outdated Show resolved Hide resolved
@rm3l
Copy link
Member

rm3l commented Jan 9, 2024

@rm3l do we need the pr.yaml to run on BOTH docker and podman? I would think we would be good enough with just podman, until such time as we want multi-arch builds upstream with docker buildx. For now, we should be fine with the simpler podman build approach, which means the local builds I do in Fedora with the makefile are the same as those done in GH action.

Do you use docker locally? If so we could switch to using docker in the GH actions...

I have both docker and podman locally, and use whatever default container engine is set in our Makefile. I didn't override it.
But I am fine with simplifying pr.yaml file as well. IIRC, it was there to ensure both targets run correctly, as we had a typo issue in one of them back then.

Copy link
Member

@rm3l rm3l left a comment

Choose a reason for hiding this comment

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

Also, in .github/workflows/pr-container-build.yaml, can you rename the pr-docker-build job (along with its name field), since it is not using Docker?

Makefile Outdated Show resolved Hide resolved
Signed-off-by: RHDH Build (rhdh-bot) <rhdh-bot@redhat.com>

BUILDPLATFORM is required by the dockerfile for cross-compilation with buildx; however the --platform flag should not be --platform=

Signed-off-by: RHDH Build (rhdh-bot) <rhdh-bot@redhat.com>
Signed-off-by: RHDH Build (rhdh-bot) <rhdh-bot@redhat.com>
@nickboldt
Copy link
Member Author

@rm3l do we need the pr.yaml to run on BOTH docker and podman? I would think we would be good enough with just podman, until such time as we want multi-arch builds upstream with docker buildx. For now, we should be fine with the simpler podman build approach, which means the local builds I do in Fedora with the makefile are the same as those done in GH action.
Do you use docker locally? If so we could switch to using docker in the GH actions...

I have both docker and podman locally, and use whatever default container engine is set in our Makefile. I didn't override it. But I am fine with simplifying pr.yaml file as well. IIRC, it was there to ensure both targets run correctly, as we had a typo issue in one of them back then.

On my machine with podman and the docker-podman wrapper (Fedora 36):

docker build --platform linux/amd64 -f docker/Dockerfile -t quay.io/janus/operator:0.0.1 --label quay.expires-after=14d .
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/build?buildargs=%7B%7D&cachefrom=%5B%5D&cgroupparent=&cpuperiod=0&cpuquota=0&cpusetcpus=&cpusetmems=&cpushares=0&dockerfile=docker%2FDockerfile&labels=%7B%22quay.expires-after%22%3A%2214d%22%7D&memory=0&memswap=0&networkmode=default&platform=linux%2Famd64&rm=1&shmsize=0&t=quay.io%2Fjanus%2Foperator%3A0.0.1&target=&ulimits=null&version=1": dial unix /var/run/docker.sock: connect: permission denied
make: *** [Makefile:148: operator-build] Error 1

I know there's a workaround for this, but I prefer to just use the tool we support inside RH. :D

@jianrongzhang89
Copy link
Contributor

@rm3l do we need the pr.yaml to run on BOTH docker and podman? I would think we would be good enough with just podman, until such time as we want multi-arch builds upstream with docker buildx. For now, we should be fine with the simpler podman build approach, which means the local builds I do in Fedora with the makefile are the same as those done in GH action.
Do you use docker locally? If so we could switch to using docker in the GH actions...

I have both docker and podman locally, and use whatever default container engine is set in our Makefile. I didn't override it. But I am fine with simplifying pr.yaml file as well. IIRC, it was there to ensure both targets run correctly, as we had a typo issue in one of them back then.

On my machine with podman and the docker-podman wrapper (Fedora 36):

docker build --platform linux/amd64 -f docker/Dockerfile -t quay.io/janus/operator:0.0.1 --label quay.expires-after=14d .
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/build?buildargs=%7B%7D&cachefrom=%5B%5D&cgroupparent=&cpuperiod=0&cpuquota=0&cpusetcpus=&cpusetmems=&cpushares=0&dockerfile=docker%2FDockerfile&labels=%7B%22quay.expires-after%22%3A%2214d%22%7D&memory=0&memswap=0&networkmode=default&platform=linux%2Famd64&rm=1&shmsize=0&t=quay.io%2Fjanus%2Foperator%3A0.0.1&target=&ulimits=null&version=1": dial unix /var/run/docker.sock: connect: permission denied
make: *** [Makefile:148: operator-build] Error 1

I know there's a workaround for this, but I prefer to just use the tool we support inside RH. :D

If you use docker you should start the docker daemon first.

@nickboldt
Copy link
Member Author

nickboldt commented Jan 9, 2024

If you use docker you should start the docker daemon first.

sudo dockerd &

make release-build
...
docker build --platform linux/amd64 -f docker/Dockerfile -t quay.io/janus/operator:0.0.1 --label quay.expires-after=14d .
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/build?buildargs=%7B%7D&cachefrom=%5B%5D&cgroupparent=&cpuperiod=0&cpuquota=0&cpusetcpus=&cpusetmems=&cpushares=0&dockerfile=docker%2FDockerfile&labels=%7B%22quay.expires-after%22%3A%2214d%22%7D&memory=0&memswap=0&networkmode=default&platform=linux%2Famd64&rm=1&shmsize=0&t=quay.io%2Fjanus%2Foperator%3A0.0.1&target=&ulimits=null&version=1": dial unix /var/run/docker.sock: connect: permission denied
make: *** [Makefile:148: operator-build] Error 1

Signed-off-by: RHDH Build (rhdh-bot) <rhdh-bot@redhat.com>
@gazarenkov
Copy link
Member

@rm3l do we need the pr.yaml to run on BOTH docker and podman? I would think we would be good enough with just podman, until such time as we want multi-arch builds upstream with docker buildx. For now, we should be fine with the simpler podman build approach, which means the local builds I do in Fedora with the makefile are the same as those done in GH action.

Do you use docker locally? If so we could switch to using docker in the GH actions...

As discussed, let's keep both of them for the time.
Yes, it is used locally.

…other pr check

Signed-off-by: RHDH Build (rhdh-bot) <rhdh-bot@redhat.com>
@nickboldt nickboldt merged commit 4ba6407 into main Jan 10, 2024
5 of 6 checks passed
@nickboldt nickboldt deleted the reuse-makefile-for-GH-actions branch January 10, 2024 16:26
nickboldt pushed a commit that referenced this pull request Jan 10, 2024
Signed-off-by: RHDH Build (rhdh-bot) <rhdh-bot@redhat.com>
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants