diff --git a/Makefile b/Makefile index f9d9b08d72..4f01f99e3c 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,8 @@ check: | verify test-unit IMAGE_REGISTRY?=registry.svc.ci.openshift.org +TAGS ?= ocp + # This will call a macro called "build-image" which will generate image specific targets based on the parameters: # $0 - macro name # $1 - target name @@ -37,6 +39,9 @@ $(call add-profile-manifests,manifests,./profile-patches,./manifests) GO_UNIT_TEST_PACKAGES :=./pkg/... ./cmd/... +build: + go build -tags '$(TAGS)' -o $@ ./cmd/console/main.go + # Run tests test: test-unit test-e2e @@ -59,6 +64,13 @@ else go-junit-report --version endif +# download the dependencies and put them in the /vendor directory. +.PHONY: vendor +vendor: + go mod tidy + go mod vendor + go mod verify + # Remove all build artifacts. # # Example: diff --git a/README.md b/README.md index 91466f3d60..dcf95466ea 100644 --- a/README.md +++ b/README.md @@ -159,28 +159,22 @@ Now we should be ready to build & deploy the operator with our changes. #### Preparation to Deploy Operator Changes Quickly -Typically to build your binary you will use the `make` command: +Typically to build your binary you would use the `make` command: ```bash -# this will build for your platform: +# this will build locally: make -# if you are running OSX, you will need to build for linux doing something like: -OS_DEBUG=true OS_BUILD_PLATFORMS=linux/amd64 make -# note that you can build for mulitiple platforms with: -make build-cross ``` -But the `make` step is included in the `Dockerfile`, so this does not need to be done manually. -You can instead simply build the container image and push the it to your own registry: +But the build step is included in the `Dockerfile.rhel7`, so this does not need to be done manually. +You can instead simply build the container image and push it to your own registry: ```bash # the pattern is: -docker build -t //console-operator: . -# following: docker.io/openshift/origin-console-operator:latest +docker build -f Dockerfile.rhel7 -t //console-operator: +# conforming to: docker.io/openshift/origin-console-operator:latest # for development, you are going to push to an alternate registry. -# specifically it can look something like this: -docker build -f Dockerfile.rhel7 -t quay.io/benjaminapetersen/console-operator:latest . ``` -You can optionally build a specific version. +Note: If you are running on macOS, you need to pass the --platform linux/amd64 flag to the Docker build command. Then, push your image: @@ -189,30 +183,16 @@ docker push //console-operator: # Be sure your repository is public else the image will not be able to be pulled later docker push quay.io/benjaminapetersen/console-operator:latest ``` -Then, you will want to deploy your new container. This means duplicating the `manifests/07-operator.yaml` -and updating the line `image: docker.io/openshift/origin-console-operator:latest` to instead use the -image you just pushed. - -```bash -# duplicate the operator manifest to /examples or your ~/ home dir -cp manifests/07-operator.yaml ~/07-operator-alt-image.yaml -``` -Then, update the image & replicas in your `07-operator-alt-image.yaml` file: +Then, you will want to deploy your new container to the cluster. This can be done by updating the `image` field in the `example/07-operator.yaml` file to instead use the image you just pushed: ```yaml # before -replicas: 2 image: docker.io/openshift/origin-console-operator:latest # after # image: //console-operator: -replicas: 1 image: quay.io/benjaminapetersen/console-operator:latest ``` -And ensure that the `imagePullPolicy` is still `Always`. This will ensure a fast development feedback loop. - -```yaml -imagePullPolicy: Always -``` +Note: To guarantee a fast development feedback loop make sure the `imagePullPolicy` is set to `Always`. #### Deploying diff --git a/examples/07-operator-alt-image.yaml b/examples/07-operator-alt-image.yaml index 38b8a0cb8c..b6e66aa120 100644 --- a/examples/07-operator-alt-image.yaml +++ b/examples/07-operator-alt-image.yaml @@ -21,7 +21,7 @@ spec: # docker build quay.io//console-operator:latest . # docker push quay.io//console-operator:latest # then - # oc apply -f examples/05-operator-alt-image.yaml + # oc apply -f examples/07-operator-alt-image.yaml # with this line updated: image: quay.io//console-operator:latest ports: