From 821b507e0e829c751231096779944002cd62ba2b Mon Sep 17 00:00:00 2001 From: Danny Avila <110412045+danny-avila@users.noreply.github.com> Date: Tue, 13 Jun 2023 12:12:27 -0400 Subject: [PATCH] fix(docker): handle .env file to read frontend vars during build easily (#513) - Remove api/.env and .env from .dockerignore file - Add COPY .env .env to Dockerfile to copy .env file to docker build - Add RUN rm .env to Dockerfile to remove .env file after build - Remove build args from docker-compose.yml file --- .dockerignore | 2 -- Dockerfile | 13 +++++-------- docker-compose.yml | 3 --- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/.dockerignore b/.dockerignore index 595651624a..51ef79175a 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,2 @@ **/node_modules -api/.env -.env client/dist/images \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index c62a2f5484..232bff081a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,22 +1,19 @@ # Base node image FROM node:19-alpine AS node COPY . /app +# Copy .env file +COPY .env .env # Install dependencies WORKDIR /app RUN npm ci -# Frontend variables as build args -ARG VITE_APP_TITLE -ARG VITE_SHOW_GOOGLE_LOGIN_OPTION - -# You will need to add your VITE variables to the docker-compose file -ENV VITE_APP_TITLE=$VITE_APP_TITLE -ENV VITE_SHOW_GOOGLE_LOGIN_OPTION=$VITE_SHOW_GOOGLE_LOGIN_OPTION - # React client build ENV NODE_OPTIONS="--max-old-space-size=2048" RUN npm run frontend +# Remove .env file after build +RUN rm .env + # Node API setup EXPOSE 3080 ENV HOST=0.0.0.0 diff --git a/docker-compose.yml b/docker-compose.yml index a97a992709..3697d2fd13 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -23,9 +23,6 @@ services: build: context: . target: node - args: - VITE_APP_TITLE: LibreChat # default, change to your desired app name - VITE_SHOW_GOOGLE_LOGIN_OPTION: false # default, change to true if you have google auth setup # image: chatgptclone/app:latest # Uncomment this & comment above to build from docker hub image restart: always # extra_hosts: # if you are running APIs on docker you need access to, you will need to uncomment this line and next