From be54ebfe7641bc40aa04d39bd08b00c571d2203c Mon Sep 17 00:00:00 2001 From: Brian Gann Date: Thu, 20 Feb 2025 01:32:56 -0500 Subject: [PATCH] adds option to build debug/dev frontend docker images --- Dockerfile | 9 +++++++-- Makefile | 20 ++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9914a48dce0..69ce7954944 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,6 +14,8 @@ ARG JS_SRC=js-builder # Javascript build stage FROM --platform=${JS_PLATFORM} ${JS_IMAGE} AS js-builder +ARG JS_NODE_ENV=production +ARG JS_YARN_BUILD_FLAG=build ENV NODE_OPTIONS=--max_old_space_size=8000 @@ -29,14 +31,17 @@ COPY e2e e2e RUN apk add --no-cache make build-base python3 +# Set the node env according to defaults or argument passed +# +ENV NODE_ENV=${JS_NODE_ENV} RUN yarn install --immutable COPY tsconfig.json eslint.config.js .editorconfig .browserslistrc .prettierrc.js ./ COPY scripts scripts COPY emails emails -ENV NODE_ENV=production -RUN yarn build +# Set the build argument according to default or argument passed +RUN yarn ${JS_YARN_BUILD_FLAG} # Golang build stage FROM ${GO_IMAGE} AS go-builder diff --git a/Makefile b/Makefile index bfc5491e782..5c152e2ff3d 100644 --- a/Makefile +++ b/Makefile @@ -342,6 +342,22 @@ shellcheck: $(SH_FILES) ## Run checks for shell scripts. TAG_SUFFIX=$(if $(WIRE_TAGS)!=oss,-$(WIRE_TAGS)) PLATFORM=linux/amd64 +# default to a production build for frontend +# +DOCKER_JS_NODE_ENV_FLAG = production +DOCKER_JS_YARN_BUILD_FLAG = build +# +# if go is in dev mode, also build node in dev mode +ifeq ($(GO_BUILD_DEV), dev) + DOCKER_JS_NODE_ENV_FLAG = dev + DOCKER_JS_YARN_BUILD_FLAG = dev +endif +# if NODE_ENV is set in the environment to dev, build frontend in dev mode, and allow go builds to use their default +ifeq (${NODE_ENV}, dev) + DOCKER_JS_NODE_ENV_FLAG = dev + DOCKER_JS_YARN_BUILD_FLAG = dev +endif + .PHONY: build-docker-full build-docker-full: ## Build Docker image for development. @echo "build docker container" @@ -349,6 +365,8 @@ build-docker-full: ## Build Docker image for development. docker buildx build - \ --platform $(PLATFORM) \ --build-arg BINGO=false \ + --build-arg NODE_ENV=$(DOCKER_JS_NODE_ENV_FLAG) \ + --build-arg JS_YARN_BUILD_FLAG=$(DOCKER_JS_YARN_BUILD_FLAG) \ --build-arg GO_BUILD_TAGS=$(GO_BUILD_TAGS) \ --build-arg WIRE_TAGS=$(WIRE_TAGS) \ --build-arg COMMIT_SHA=$$(git rev-parse HEAD) \ @@ -363,6 +381,8 @@ build-docker-full-ubuntu: ## Build Docker image based on Ubuntu for development. docker buildx build - \ --platform $(PLATFORM) \ --build-arg BINGO=false \ + --build-arg NODE_ENV=$(DOCKER_JS_NODE_ENV_FLAG) \ + --build-arg JS_YARN_BUILD_FLAG=$(DOCKER_JS_YARN_BUILD_FLAG) \ --build-arg GO_BUILD_TAGS=$(GO_BUILD_TAGS) \ --build-arg WIRE_TAGS=$(WIRE_TAGS) \ --build-arg COMMIT_SHA=$$(git rev-parse HEAD) \