From 67d217ca1297d75b94721c6f4af8374d1317768e Mon Sep 17 00:00:00 2001 From: dvirlabs <114520947+dvirlabs@users.noreply.github.com> Date: Tue, 23 Dec 2025 21:27:42 +0200 Subject: [PATCH] Update dynamic values --- .gitignore | 2 +- frontend/.env.example | 1 + frontend/Dockerfile | 5 +++++ frontend/index.html | 1 + frontend/src/App.jsx | 2 +- 5 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 frontend/.env.example diff --git a/.gitignore b/.gitignore index 56a655a..8515a37 100644 --- a/.gitignore +++ b/.gitignore @@ -27,4 +27,4 @@ env/ Thumbs.db my-recipes-chart/\ -helm/ \ No newline at end of file +ipify-chart/ \ No newline at end of file diff --git a/frontend/.env.example b/frontend/.env.example new file mode 100644 index 0000000..5934e2e --- /dev/null +++ b/frontend/.env.example @@ -0,0 +1 @@ +VITE_API_URL=http://localhost:8000 diff --git a/frontend/Dockerfile b/frontend/Dockerfile index f4b0b8c..7fc1183 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -24,6 +24,11 @@ COPY --from=build /app/dist /usr/share/nginx/html # Copy nginx configuration COPY nginx.conf /etc/nginx/conf.d/default.conf +# Create entrypoint script to inject env variables +RUN echo '#!/bin/sh' > /docker-entrypoint.d/40-generate-env.sh && \ + echo 'echo "window.ENV = { VITE_API_URL: \"${VITE_API_URL}\" };" > /usr/share/nginx/html/env.js' >> /docker-entrypoint.d/40-generate-env.sh && \ + chmod +x /docker-entrypoint.d/40-generate-env.sh + # Expose port EXPOSE 80 diff --git a/frontend/index.html b/frontend/index.html index 90e22ff..a39d881 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -4,6 +4,7 @@ IP Subnet Calculator +
diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index b9c84e3..d32b4f4 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -2,7 +2,7 @@ import { useState } from 'react' import axios from 'axios' import './App.css' -const API_URL = 'http://localhost:8000' +const API_URL = window.ENV?.VITE_API_URL || 'http://localhost:8000' function App() { const [ipAddress, setIpAddress] = useState('')