From fffded7cb4da2f45f15918d479da9829b652b425 Mon Sep 17 00:00:00 2001 From: Michael Pleshakov Date: Tue, 30 Jan 2018 11:35:31 +0300 Subject: [PATCH] Add docker build options to Makefile --- nginx-controller/Makefile | 3 ++- nginx-controller/README.md | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/nginx-controller/Makefile b/nginx-controller/Makefile index 53b4c423fc..ae7933d911 100644 --- a/nginx-controller/Makefile +++ b/nginx-controller/Makefile @@ -11,6 +11,7 @@ DOCKERFILE = Dockerfile BUILD_IN_CONTAINER = 1 PUSH_TO_GCR = GENERATE_DEFAULT_CERT_AND_KEY = +DOCKER_BUILD_OPTIONS = GIT_COMMIT=$(shell git rev-parse --short HEAD) @@ -34,7 +35,7 @@ ifeq ($(GENERATE_DEFAULT_CERT_AND_KEY),1) endif container: test nginx-ingress certificate-and-key - docker build -f $(DOCKERFILE) -t $(PREFIX):$(TAG) . + docker build $(DOCKER_BUILD_OPTIONS) -f $(DOCKERFILE) -t $(PREFIX):$(TAG) . push: container ifeq ($(PUSH_TO_GCR),1) diff --git a/nginx-controller/README.md b/nginx-controller/README.md index f469121465..55b5cb7c8b 100644 --- a/nginx-controller/README.md +++ b/nginx-controller/README.md @@ -38,6 +38,7 @@ The **Makefile** contains the following main variables, which you should customi 1. `DockerfileForAlpine`, for building an alpine-based image with NGINX. 1. `DockerfileForPlus`, for building an ubuntu-based image with NGINX Plus. * **GENERATE_DEFAULT_CERT_AND_KEY** - The Ingress controller requires a certificate and a key for the default HTTP/HTTPS server. You can reference them in a TLS Secret in a command-line argument to the Ingress controller. As an alternative, you can add a file in the PEM format with your certificate and key to the image as `/etc/nginx/secrets/default`. Optionally, you can generate a self-signed certificate and a key during the build process. Set `GENERATE_DEFAULT_CERT_AND_KEY` to `1` to generate a certificate and a key in the `default.pem` file. Note that you must add the `ADD` instruction in the Dockerfile to copy the cert and the key to the image. The default value of `GENERATE_DEFAULT_CERT_AND_KEY` is `0`. +* **DOCKER_BUILD_OPTIONS** -- the [options](https://docs.docker.com/engine/reference/commandline/build/#options) for the `docker build` command. For example, `--pull`. Let’s create the controller binary, build an image and push the image to the private registry. Make sure to run the `docker login` command first to login to the registry. If you’re using Google Container Registry, as we are in our example here, you don’t need to use the docker command to login. However, make sure you’re logged into the gcloud tool (using the `gcloud auth login` command).