From 3d0fbd0065e6ae775fa8ecf380fb69393aff5145 Mon Sep 17 00:00:00 2001 From: Prashant Shahi Date: Fri, 29 Sep 2023 17:10:14 +0530 Subject: [PATCH] perf(frontend): :hammer: improve frontend build time (#3653) Signed-off-by: Prashant Shahi --- Makefile | 16 ++++++++++++++-- frontend/.dockerignore | 1 - frontend/Dockerfile | 31 +++++-------------------------- 3 files changed, 19 insertions(+), 29 deletions(-) diff --git a/Makefile b/Makefile index 7d976341c1f..d4df55c063a 100644 --- a/Makefile +++ b/Makefile @@ -37,10 +37,22 @@ LD_FLAGS=-X ${buildHash}=${BUILD_HASH} -X ${buildTime}=${BUILD_TIME} -X ${buildV DEV_LD_FLAGS=-X ${licenseSignozIo}=${DEV_LICENSE_SIGNOZ_IO} all: build-push-frontend build-push-query-service + +# Steps to build static files of frontend +build-frontend-static: + @echo "------------------" + @echo "--> Building frontend static files" + @echo "------------------" + @cd $(FRONTEND_DIRECTORY) && \ + rm -rf build && \ + CI=1 yarn install && \ + yarn build && \ + ls -l build + # Steps to build and push docker image of frontend .PHONY: build-frontend-amd64 build-push-frontend # Step to build docker image of frontend in amd64 (used in build pipeline) -build-frontend-amd64: +build-frontend-amd64: build-frontend-static @echo "------------------" @echo "--> Building frontend docker image for amd64" @echo "------------------" @@ -49,7 +61,7 @@ build-frontend-amd64: --build-arg TARGETPLATFORM="linux/amd64" . # Step to build and push docker image of frontend(used in push pipeline) -build-push-frontend: +build-push-frontend: build-frontend-static @echo "------------------" @echo "--> Building and pushing frontend docker image" @echo "------------------" diff --git a/frontend/.dockerignore b/frontend/.dockerignore index a106e6a11e9..840adcb19f8 100644 --- a/frontend/.dockerignore +++ b/frontend/.dockerignore @@ -1,4 +1,3 @@ node_modules .vscode -build .git diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 32090527995..ddbf9edc19b 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -1,38 +1,17 @@ -# Builder stage -FROM node:16.15.0 as builder +FROM nginx:1.25.2-alpine # Add Maintainer Info LABEL maintainer="signoz" -ARG TARGETOS=linux -ARG TARGETARCH - +# Set working directory WORKDIR /frontend -# Copy the package.json and .yarnrc files prior to install dependencies -COPY package.json ./ -# Copy lock file -COPY yarn.lock ./ -COPY .yarnrc ./ - -# Install the dependencies and make the folder -RUN CI=1 yarn install - -COPY . . - -# Build the project and copy the files -RUN yarn build - - -FROM nginx:1.25.2-alpine - -COPY conf/default.conf /etc/nginx/conf.d/default.conf - # Remove default nginx index page RUN rm -rf /usr/share/nginx/html/* -# Copy from the stahg 1 -COPY --from=builder /frontend/build /usr/share/nginx/html +# Copy custom nginx config and static files +COPY conf/default.conf /etc/nginx/conf.d/default.conf +COPY build /usr/share/nginx/html EXPOSE 3301