Skip to content

Commit

Permalink
perf(frontend): 🔨 improve frontend build time (#3653)
Browse files Browse the repository at this point in the history
Signed-off-by: Prashant Shahi <prashant@signoz.io>
  • Loading branch information
prashant-shahi authored Sep 29, 2023
1 parent 05ea814 commit 3d0fbd0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 29 deletions.
16 changes: 14 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 "------------------"
Expand All @@ -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 "------------------"
Expand Down
1 change: 0 additions & 1 deletion frontend/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
node_modules
.vscode
build
.git
31 changes: 5 additions & 26 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit 3d0fbd0

Please sign in to comment.