Build: Adds option to build debug frontend docker images (#108202)
* Add env support for different build environment targets * Add NX target for dev builds * Add option to build in dev mode * skip immutable flag for dev builds
This commit is contained in:
+15
-5
@@ -18,9 +18,11 @@ FROM alpine:3.21.3 AS alpine-base
|
||||
FROM ubuntu:22.04 AS ubuntu-base
|
||||
FROM golang:1.24.6-alpine AS go-builder-base
|
||||
FROM --platform=${JS_PLATFORM} node:22-alpine AS js-builder-base
|
||||
|
||||
# Javascript build stage
|
||||
FROM --platform=${JS_PLATFORM} ${JS_IMAGE} AS js-builder
|
||||
ARG JS_NODE_ENV=production
|
||||
ARG JS_YARN_INSTALL_FLAG=--immutable
|
||||
ARG JS_YARN_BUILD_FLAG=build
|
||||
|
||||
ENV NODE_OPTIONS=--max_old_space_size=8000
|
||||
|
||||
@@ -35,15 +37,23 @@ COPY conf/defaults.ini ./conf/defaults.ini
|
||||
COPY e2e e2e
|
||||
|
||||
RUN apk add --no-cache make build-base python3
|
||||
|
||||
RUN yarn install --immutable
|
||||
#
|
||||
# Set the node env according to defaults or argument passed
|
||||
#
|
||||
ENV NODE_ENV=${JS_NODE_ENV}
|
||||
#
|
||||
RUN if [ "$JS_YARN_INSTALL_FLAG" = "" ]; then \
|
||||
yarn install; \
|
||||
else \
|
||||
yarn install --immutable; \
|
||||
fi
|
||||
|
||||
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
|
||||
|
||||
@@ -400,13 +400,36 @@ 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
|
||||
DOCKER_JS_YARN_INSTALL_FLAG = --immutable
|
||||
#
|
||||
# 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
|
||||
DOCKER_JS_YARN_INSTALL_FLAG =
|
||||
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
|
||||
DOCKER_JS_YARN_INSTALL_FLAG =
|
||||
endif
|
||||
|
||||
.PHONY: build-docker-full
|
||||
build-docker-full: ## Build Docker image for development.
|
||||
@echo "build docker container"
|
||||
@echo "build docker container mode=($(DOCKER_JS_NODE_ENV_FLAG))"
|
||||
tar -ch . | \
|
||||
docker buildx build - \
|
||||
--platform $(PLATFORM) \
|
||||
--build-arg BINGO=false \
|
||||
--build-arg NODE_ENV=$(DOCKER_JS_NODE_ENV_FLAG) \
|
||||
--build-arg JS_NODE_ENV=$(DOCKER_JS_NODE_ENV_FLAG) \
|
||||
--build-arg JS_YARN_INSTALL_FLAG=$(DOCKER_JS_YARN_INSTALL_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) \
|
||||
@@ -416,11 +439,15 @@ build-docker-full: ## Build Docker image for development.
|
||||
|
||||
.PHONY: build-docker-full-ubuntu
|
||||
build-docker-full-ubuntu: ## Build Docker image based on Ubuntu for development.
|
||||
@echo "build docker container"
|
||||
@echo "build docker container mode=($(DOCKER_JS_NODE_ENV_FLAG))"
|
||||
tar -ch . | \
|
||||
docker buildx build - \
|
||||
--platform $(PLATFORM) \
|
||||
--build-arg BINGO=false \
|
||||
--build-arg NODE_ENV=$(DOCKER_JS_NODE_ENV_FLAG) \
|
||||
--build-arg JS_NODE_ENV=$(DOCKER_JS_NODE_ENV_FLAG) \
|
||||
--build-arg JS_YARN_INSTALL_FLAG=$(DOCKER_JS_YARN_INSTALL_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) \
|
||||
@@ -546,4 +573,3 @@ help: ## Display this help.
|
||||
# container/check-licenses target)
|
||||
check-licenses:
|
||||
license_finder --decisions-file .github/license_finder.yaml
|
||||
|
||||
|
||||
@@ -23,6 +23,17 @@
|
||||
"outputs": ["{workspaceRoot}/public/build"],
|
||||
"cache": true
|
||||
},
|
||||
"dev": {
|
||||
"dependsOn": [
|
||||
"themes-generate",
|
||||
{
|
||||
"projects": ["tag:scope:plugin"],
|
||||
"target": "build"
|
||||
}
|
||||
],
|
||||
"outputs": ["{workspaceRoot}/public/build"],
|
||||
"cache": true
|
||||
},
|
||||
"themes-generate": {
|
||||
"inputs": [
|
||||
"{workspaceRoot}/scripts/cli/generateSassVariableFiles.ts",
|
||||
|
||||
Reference in New Issue
Block a user