Skip to content

LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows

refactor: FE dockerfile optimized for better caching (#1125)

Chandrasekharan M6538bcad44c0
diff --git a/docker/dockerfiles/frontend.Dockerfile b/docker/dockerfiles/frontend.Dockerfile
index 242e3f4a1..33468d897 100644
--- a/docker/dockerfiles/frontend.Dockerfile
+++ b/docker/dockerfiles/frontend.Dockerfile
@@ -1,29 +1,37 @@
-FROM node:16 AS builder
+# Use a smaller base image for the builder stage
+FROM node:16-alpine AS builder
# Build-time environment variables
-ENV BUILD_CONTEXT_PATH frontend
-ENV REACT_APP_BACKEND_URL ""
+ENV BUILD_CONTEXT_PATH=frontend
+ENV REACT_APP_BACKEND_URL=""
# Set the working directory inside the container
WORKDIR /app
-COPY ${BUILD_CONTEXT_PATH}/ .
+# Copy only the files needed for installing dependencies
+COPY ${BUILD_CONTEXT_PATH}/package.json ${BUILD_CONTEXT_PATH}/package-lock.json ./
+
+# Install dependencies (this layer will be cached unless package.json or package-lock.json changes)
+RUN npm install --ignore-scripts
-RUN set -e; \
- # Install app dependencies
- npm install --ignore-scripts; \
- # Build the React app
- npm run build;
+# Copy the rest of the application files
+COPY ${BUILD_CONTEXT_PATH}/ .
+# Build the React app
+RUN npm run build
-FROM nginx:1.25
+# Use a smaller base image for the final stage
+FROM nginx:1.25-alpine
LABEL maintainer="Zipstack Inc."
-# Remove the default NGINX configuration
+# Remove the default NGINX configuration (if needed)
# RUN rm /etc/nginx/conf.d/default.conf
+# Copy built assets from the builder stage
COPY --from=builder /app/build /usr/share/nginx/html
+
+# Copy custom NGINX configuration
COPY --from=builder /app/nginx.conf /etc/nginx/nginx.conf
EXPOSE 80