Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run yarn build when starting up frontend container #1021

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
# Step 1: Build the React application
FROM node:20 AS build
FROM quay.io/centos/centos:stream9-minimal

ARG VITE_BACKEND_API_URL="http://localhost:8000"
ARG VITE_REACT_APP_SOURCES=""
ARG VITE_LLM_MODELS=""
ARG VITE_GOOGLE_CLIENT_ID=""
ARG VITE_BLOOM_URL="https://workspace-preview.neo4j.io/workspace/explore?connectURL={CONNECT_URL}&search=Show+me+a+graph&featureGenAISuggestions=true&featureGenAISuggestionsInternal=true"
#ARG VITE_BLOOM_URL="https://workspace-preview.neo4j.io/workspace/explore?connectURL={CONNECT_URL}&search=Show+me+a+graph&featureGenAISuggestions=true&featureGenAISuggestionsInternal=true"
ARG VITE_BLOOM_URL=""
ARG VITE_TIME_PER_PAGE=50
ARG VITE_LARGE_FILE_SIZE=5242880
ARG VITE_CHUNK_SIZE=5242880
ARG VITE_CHAT_MODES=""
ARG VITE_ENV="DEV"
ARG VITE_BATCH_SIZE=2
ARG VITE_LLM_MODELS_PROD="openai_gpt_4o,openai_gpt_4o_mini,diffbot,gemini_1.5_flash"
ARG DEPLOYMENT_ENV="prod"
ENV DEPLOYMENT_ENV=$DEPLOYMENT_ENV

WORKDIR /app
RUN microdnf install findutils tar gzip bzip2 nginx -y && microdnf clean all
ADD https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh /tmp/nvm-install.sh
RUN bash /tmp/nvm-install.sh && source /root/.bashrc && nvm install --lts && nvm use --lts && corepack use yarn && corepack enable
COPY package.json yarn.lock ./
RUN yarn install
RUN source /root/.bashrc && yarn install
COPY . ./
RUN VITE_BACKEND_API_URL=$VITE_BACKEND_API_URL \
RUN source /root/.bashrc && ls && yarn install && \
VITE_BACKEND_API_URL=$VITE_BACKEND_API_URL \
VITE_REACT_APP_SOURCES=$VITE_REACT_APP_SOURCES \
VITE_GOOGLE_CLIENT_ID=$VITE_GOOGLE_CLIENT_ID \
VITE_BLOOM_URL=$VITE_BLOOM_URL \
Expand All @@ -32,12 +39,10 @@ RUN VITE_BACKEND_API_URL=$VITE_BACKEND_API_URL \
VITE_LLM_MODELS_PROD=$VITE_LLM_MODELS_PROD \
yarn run build

# Step 2: Serve the application using Nginx
FROM nginx:alpine
ARG DEPLOYMENT_ENV="local"
ENV DEPLOYMENT_ENV=$DEPLOYMENT_ENV
COPY --from=build /app/dist /usr/share/nginx/html
COPY /nginx/nginx.${DEPLOYMENT_ENV}.conf /etc/nginx/templates/nginx.conf.template
COPY . ./
RUN rm -rf /usr/share/nginx/html && ln -s /app/dist /usr/share/nginx/html
COPY /nginx/nginx.${DEPLOYMENT_ENV}.conf /etc/nginx/conf.d/nginx.${DEPLOYMENT_ENV}.conf
ADD entrypoint.sh /bin/

EXPOSE 8080
CMD ["nginx", "-g", "daemon off;"]
CMD ["bash", "/bin/entrypoint.sh"]
7 changes: 7 additions & 0 deletions frontend/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

cd /usr/share/nginx/html
source /root/.bashrc
yarn run build
nginx -g "daemon off;"