From 9c27c41a5eefc44a6385c501ad94d445d3f4ec54 Mon Sep 17 00:00:00 2001 From: chamikaJ Date: Fri, 25 Apr 2025 16:42:45 +0530 Subject: [PATCH] Add script to inject environment variables in Dockerfile - Created a start.sh script to set environment variables for the application. - Updated CMD to execute the new script instead of directly serving the build. --- worklenz-frontend/Dockerfile | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/worklenz-frontend/Dockerfile b/worklenz-frontend/Dockerfile index ac1f820f..5b1c338d 100644 --- a/worklenz-frontend/Dockerfile +++ b/worklenz-frontend/Dockerfile @@ -16,5 +16,16 @@ WORKDIR /app RUN npm install -g serve COPY --from=build /app/build /app/build + +# Create a script to inject environment variables +RUN echo '#!/bin/sh\n\ +cat > /app/build/env.js << EOL\n\ +window.env = {\n\ + VITE_API_URL: "${VITE_API_URL}"\n\ +};\n\ +EOL\n\ +exec serve -s build -l 5000' > /app/start.sh && \ +chmod +x /app/start.sh + EXPOSE 5000 -CMD ["serve", "-s", "build", "-l", "5000"] \ No newline at end of file +CMD ["/app/start.sh"] \ No newline at end of file