Skip to content

Commit fe28bc5

Browse files
committed
Fix builder docker image (nginx#988)
Problem: The builder docker image was out of date and didn't copy the correct files. Solution: Copy the whole directory and run the make command to ensure everything is always in sync.
1 parent 4637487 commit fe28bc5

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ OUT_DIR ?= $(shell pwd)/build/out## The folder where the binary will be stored
2222
ARCH ?= amd64## The architecture of the image and/or binary. For example: amd64 or arm64
2323
override HELM_TEMPLATE_COMMON_ARGS += --set creator=template --set nameOverride=nginx-gateway## The common options for the Helm template command.
2424
override HELM_TEMPLATE_EXTRA_ARGS_FOR_ALL_MANIFESTS_FILE += --include-crds --set service.create=false## The options to be passed to the full Helm templating command only.
25-
override DOCKER_BUILD_OPTIONS += --build-arg VERSION=$(VERSION) --build-arg GIT_COMMIT=$(GIT_COMMIT) --build-arg DATE=$(DATE)## The options for the docker build command. For example, --pull
2625
override NGINX_DOCKER_BUILD_OPTIONS += --build-arg NJS_DIR=$(NJS_DIR) --build-arg NGINX_CONF_DIR=$(NGINX_CONF_DIR)
2726
.DEFAULT_GOAL := help
2827

@@ -36,7 +35,7 @@ build-images: build-nkg-image build-nginx-image ## Build the NKG and nginx docke
3635

3736
.PHONY: build-nkg-image
3837
build-nkg-image: check-for-docker build ## Build the NKG docker image
39-
docker build --platform linux/$(ARCH) $(strip $(DOCKER_BUILD_OPTIONS)) --target $(strip $(TARGET)) -f build/Dockerfile -t $(strip $(PREFIX)):$(strip $(TAG)) .
38+
docker build --platform linux/$(ARCH) --target $(strip $(TARGET)) -f build/Dockerfile -t $(strip $(PREFIX)):$(strip $(TAG)) .
4039

4140
.PHONY: build-nginx-image
4241
build-nginx-image: check-for-docker ## Build the custom nginx image

build/Dockerfile

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
# syntax=docker/dockerfile:1.4
22
FROM golang:1.21 as builder
3-
ARG VERSION
4-
ARG GIT_COMMIT
5-
ARG DATE
63

7-
WORKDIR /go/src/github.com/nginxinc/nginx-kubernetes-gateway/cmd/gateway
4+
WORKDIR /go/src/github.com/nginxinc/nginx-kubernetes-gateway
85

96
COPY go.mod go.sum /go/src/github.com/nginxinc/nginx-kubernetes-gateway
107
RUN go mod download
118

12-
COPY cmd /go/src/github.com/nginxinc/nginx-kubernetes-gateway/cmd
13-
COPY internal /go/src/github.com/nginxinc/nginx-kubernetes-gateway/internal
14-
COPY pkg /go/src/github.com/nginxinc/nginx-kubernetes-gateway/pkg
15-
RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -a -ldflags "-s -w -X main.version=${VERSION} -X main.commit=${GIT_COMMIT} -X main.date=${DATE}" -o gateway .
9+
COPY . /go/src/github.com/nginxinc/nginx-kubernetes-gateway
10+
RUN make build
1611

1712
FROM alpine:3.18 as capabilizer
1813
RUN apk add --no-cache libcap
@@ -22,7 +17,7 @@ COPY ./build/out/gateway /usr/bin/
2217
RUN setcap 'cap_kill=+ep' /usr/bin/gateway
2318

2419
FROM capabilizer as container-capabilizer
25-
COPY --from=builder /go/src/github.com/nginxinc/nginx-kubernetes-gateway/cmd/gateway/gateway /usr/bin/
20+
COPY --from=builder /go/src/github.com/nginxinc/nginx-kubernetes-gateway/build/out/gateway /usr/bin/
2621
RUN setcap 'cap_kill=+ep' /usr/bin/gateway
2722

2823
FROM capabilizer as goreleaser-capabilizer

0 commit comments

Comments
 (0)