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.
This commit is contained in:
@@ -16,5 +16,16 @@ WORKDIR /app
|
|||||||
RUN npm install -g serve
|
RUN npm install -g serve
|
||||||
|
|
||||||
COPY --from=build /app/build /app/build
|
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
|
EXPOSE 5000
|
||||||
CMD ["serve", "-s", "build", "-l", "5000"]
|
CMD ["/app/start.sh"]
|
||||||
Reference in New Issue
Block a user