Skip to content

Commit

Permalink
Fix setting build args. PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Dean-Coakley committed Jan 24, 2020
1 parent 932080f commit 0008a51
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 11 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,5 @@ cmd/nginx-ingress/nginx-ingress
# Default certificate and key
default.pem

# Dockerfiles for building
/Dockerfile

# IntelliJ IDEA
.idea
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ VERSION = edge
TAG = $(VERSION)
PREFIX = nginx/nginx-ingress

GOLANG_CONTAINER = golang:1.13
DOCKERFILEPATH = build
DOCKERFILE = Dockerfile # note, this can be overwritten e.g. can be DOCKERFILE=DockerFileForPlus

Expand All @@ -12,7 +13,7 @@ PUSH_TO_GCR =
GENERATE_DEFAULT_CERT_AND_KEY =
DOCKER_BUILD_OPTIONS =

GIT_COMMIT=$(shell git rev-parse --short HEAD)
GIT_COMMIT = $(shell git rev-parse --short HEAD)

export DOCKER_BUILDKIT = 1

Expand Down Expand Up @@ -44,7 +45,7 @@ endif

container: test verify-codegen binary certificate-and-key
ifeq ($(BUILD_IN_CONTAINER),1)
docker build $(DOCKER_BUILD_OPTIONS) --build-arg IC_VERSION=$(VERSION)-$(GIT_COMMIT) --target container -f $(DOCKERFILEPATH)/$(DOCKERFILE) -t $(PREFIX):$(TAG) .
docker build $(DOCKER_BUILD_OPTIONS) --build-arg IC_VERSION=$(VERSION)-$(GIT_COMMIT) --build-arg GIT_COMMIT=$(GIT_COMMIT) --build-arg VERSION=$(VERSION) --build-arg GOLANG_CONTAINER=$(GOLANG_CONTAINER) --target container -f $(DOCKERFILEPATH)/$(DOCKERFILE) -t $(PREFIX):$(TAG) .
else
docker build $(DOCKER_BUILD_OPTIONS) --build-arg IC_VERSION=$(VERSION)-$(GIT_COMMIT) --target local -f $(DOCKERFILEPATH)/$(DOCKERFILE) -t $(PREFIX):$(TAG) .
endif
Expand Down
6 changes: 5 additions & 1 deletion build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ARG GOLANG_CONTAINER

FROM nginx:1.17.7 AS base

# forward nginx access and error logs to stdout and stderr of the ingress
Expand Down Expand Up @@ -36,7 +38,9 @@ FROM base AS local
COPY nginx-ingress /


FROM golang:1.13 AS builder
FROM $GOLANG_CONTAINER AS builder
ARG VERSION
ARG GIT_COMMIT
WORKDIR /go/src/github.com/nginxinc/kubernetes-ingress/nginx-ingress/cmd/nginx-ingress
COPY . /go/src/github.com/nginxinc/kubernetes-ingress/nginx-ingress/
RUN CGO_ENABLED=0 GOFLAGS='-mod=vendor' \
Expand Down
6 changes: 5 additions & 1 deletion build/DockerfileForAlpine
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ARG GOLANG_CONTAINER

FROM nginx:1.17.7-alpine AS base

# forward nginx access and error logs to stdout and stderr of the ingress
Expand Down Expand Up @@ -35,7 +37,9 @@ FROM base AS local
COPY nginx-ingress /


FROM golang:1.13 AS builder
FROM $GOLANG_CONTAINER AS builder
ARG VERSION
ARG GIT_COMMIT
WORKDIR /go/src/github.com/nginxinc/kubernetes-ingress/nginx-ingress/cmd/nginx-ingress
COPY . /go/src/github.com/nginxinc/kubernetes-ingress/nginx-ingress/
RUN CGO_ENABLED=0 GOFLAGS='-mod=vendor' \
Expand Down
6 changes: 5 additions & 1 deletion build/DockerfileForPlus
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ARG GOLANG_CONTAINER

FROM debian:stretch-slim AS base

LABEL maintainer="NGINX Docker Maintainers <[email protected]>"
Expand Down Expand Up @@ -77,7 +79,9 @@ FROM base AS local
COPY nginx-ingress /


FROM golang:1.13 AS builder
FROM $GOLANG_CONTAINER AS builder
ARG VERSION
ARG GIT_COMMIT
WORKDIR /go/src/github.com/nginxinc/kubernetes-ingress/nginx-ingress/cmd/nginx-ingress
COPY . /go/src/github.com/nginxinc/kubernetes-ingress/nginx-ingress/
RUN CGO_ENABLED=0 GOFLAGS='-mod=vendor' \
Expand Down
5 changes: 4 additions & 1 deletion build/DockerfileWithOpentracing
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
ARG NGINX_VERSION=1.17.7
ARG OPENTRACING_CPP_VERSION=1.5.1
ARG GOLANG_CONTAINER

FROM nginx:${NGINX_VERSION} AS opentracing-builder
ARG OPENTRACING_CPP_VERSION
Expand Down Expand Up @@ -102,7 +103,9 @@ FROM base AS local
COPY nginx-ingress /


FROM golang:1.13 AS builder
FROM $GOLANG_CONTAINER AS builder
ARG VERSION
ARG GIT_COMMIT
WORKDIR /go/src/github.com/nginxinc/kubernetes-ingress/nginx-ingress/cmd/nginx-ingress
COPY . /go/src/github.com/nginxinc/kubernetes-ingress/nginx-ingress/
RUN CGO_ENABLED=0 GOFLAGS='-mod=vendor' \
Expand Down
3 changes: 3 additions & 0 deletions build/DockerfileWithOpentracingForPlus
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ ENV NGINX_PLUS_VERSION 20-1~stretch
ENV NGINX_OPENTRACING_MODULE_VERSION 20+0.9.0-1~stretch

ARG IC_VERSION
ARG GOLANG_CONTAINER

# Download certificate and key from the customer portal (https://cs.nginx.com)
# and copy to the build context
Expand Down Expand Up @@ -94,6 +95,8 @@ COPY nginx-ingress /


FROM golang:1.13 AS builder
ARG VERSION
ARG GIT_COMMIT
WORKDIR /go/src/github.com/nginxinc/kubernetes-ingress/nginx-ingress/cmd/nginx-ingress
COPY . /go/src/github.com/nginxinc/kubernetes-ingress/nginx-ingress/
RUN CGO_ENABLED=0 GOFLAGS='-mod=vendor' \
Expand Down
4 changes: 2 additions & 2 deletions docs-web/installation/building-ingress-controller-image.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ Next you will find the details about available Makefile targets and variables.
### Makefile Targets
The **Makefile** we provide has the following targets:
* **test**: runs unit tests.
* **binary**: creates the controller binary.
* **test**: runs unit tests (ignored when `BUILD_IN_CONTAINER` is `1`).
* **binary**: creates the controller binary using local golang environment (ignored when `BUILD_IN_CONTAINER` is `1`).
* **container**: builds a Docker image.
* **push**: pushes the image to the private Docker registry.
* **all** (the default target): executes the four targets above in the order listed. If one of the targets fails, the execution process stops, reporting an error.
Expand Down

0 comments on commit 0008a51

Please sign in to comment.