Fix VITE_API_BASE_URL not being used at runtime in Docker (#4810)
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -8,10 +8,10 @@ COPY ./skyvern-frontend /app
|
|||||||
COPY ./entrypoint-skyvernui.sh /app/entrypoint-skyvernui.sh
|
COPY ./entrypoint-skyvernui.sh /app/entrypoint-skyvernui.sh
|
||||||
RUN npm install
|
RUN npm install
|
||||||
|
|
||||||
ENV VITE_API_BASE_URL=http://localhost:8000/api/v1
|
# Placeholders for runtime injection (will be replaced by entrypoint script)
|
||||||
ENV VITE_WSS_BASE_URL=ws://localhost:8000/api/v1
|
ENV VITE_API_BASE_URL=__VITE_API_BASE_URL_PLACEHOLDER__
|
||||||
ENV VITE_ARTIFACT_API_BASE_URL=http://localhost:9090
|
ENV VITE_WSS_BASE_URL=__VITE_WSS_BASE_URL_PLACEHOLDER__
|
||||||
# Placeholder for runtime injection
|
ENV VITE_ARTIFACT_API_BASE_URL=__VITE_ARTIFACT_API_BASE_URL_PLACEHOLDER__
|
||||||
ENV VITE_SKYVERN_API_KEY=__SKYVERN_API_KEY_PLACEHOLDER__
|
ENV VITE_SKYVERN_API_KEY=__SKYVERN_API_KEY_PLACEHOLDER__
|
||||||
|
|
||||||
# Build at image time
|
# Build at image time
|
||||||
|
|||||||
@@ -2,14 +2,25 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# Extract API key from secrets file
|
# Default values for environment variables
|
||||||
VITE_SKYVERN_API_KEY=$(sed -n 's/.*cred\s*=\s*"\([^"]*\)".*/\1/p' .streamlit/secrets.toml 2>/dev/null || echo "")
|
VITE_API_BASE_URL="${VITE_API_BASE_URL:-http://localhost:8000/api/v1}"
|
||||||
|
VITE_WSS_BASE_URL="${VITE_WSS_BASE_URL:-ws://localhost:8000/api/v1}"
|
||||||
|
VITE_ARTIFACT_API_BASE_URL="${VITE_ARTIFACT_API_BASE_URL:-http://localhost:9090}"
|
||||||
|
|
||||||
# Inject API key into pre-built JS files (replace placeholder)
|
# Extract API key from secrets file if not provided via environment
|
||||||
if [ -n "$VITE_SKYVERN_API_KEY" ]; then
|
if [ -z "$VITE_SKYVERN_API_KEY" ]; then
|
||||||
find /app/dist -name "*.js" -exec sed -i "s/__SKYVERN_API_KEY_PLACEHOLDER__/$VITE_SKYVERN_API_KEY/g" {} \;
|
VITE_SKYVERN_API_KEY=$(sed -n 's/.*cred\s*=\s*"\([^"]*\)".*/\1/p' .streamlit/secrets.toml 2>/dev/null || echo "")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Inject environment variables into pre-built JS files (replace placeholders)
|
||||||
|
# Using | as delimiter since URLs contain /
|
||||||
|
find /app/dist -name "*.js" -exec sed -i \
|
||||||
|
-e "s|__VITE_API_BASE_URL_PLACEHOLDER__|${VITE_API_BASE_URL}|g" \
|
||||||
|
-e "s|__VITE_WSS_BASE_URL_PLACEHOLDER__|${VITE_WSS_BASE_URL}|g" \
|
||||||
|
-e "s|__VITE_ARTIFACT_API_BASE_URL_PLACEHOLDER__|${VITE_ARTIFACT_API_BASE_URL}|g" \
|
||||||
|
-e "s|__SKYVERN_API_KEY_PLACEHOLDER__|${VITE_SKYVERN_API_KEY}|g" \
|
||||||
|
{} \;
|
||||||
|
|
||||||
# Start the servers (no rebuild needed)
|
# Start the servers (no rebuild needed)
|
||||||
# Tini (configured as ENTRYPOINT) handles signal forwarding and zombie reaping
|
# Tini (configured as ENTRYPOINT) handles signal forwarding and zombie reaping
|
||||||
node localServer.js &
|
node localServer.js &
|
||||||
|
|||||||
Reference in New Issue
Block a user