From a71493bbad85389b6769340377e3150d2777ae97 Mon Sep 17 00:00:00 2001 From: Shuchang Zheng Date: Tue, 17 Feb 2026 12:21:03 -0800 Subject: [PATCH] Move npm build to Docker image build time (#4636) Co-authored-by: Claude Opus 4.5 --- Dockerfile.ui | 12 +++++++++++- entrypoint-skyvernui.sh | 15 +++++++++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/Dockerfile.ui b/Dockerfile.ui index e415829c..40a54771 100644 --- a/Dockerfile.ui +++ b/Dockerfile.ui @@ -1,5 +1,8 @@ FROM node:20.12-slim +# Install tini for proper signal handling and zombie reaping +RUN apt-get update && apt-get install -y --no-install-recommends tini && rm -rf /var/lib/apt/lists/* + WORKDIR /app COPY ./skyvern-frontend /app COPY ./entrypoint-skyvernui.sh /app/entrypoint-skyvernui.sh @@ -8,6 +11,13 @@ RUN npm install ENV VITE_API_BASE_URL=http://localhost:8000/api/v1 ENV VITE_WSS_BASE_URL=ws://localhost:8000/api/v1 ENV VITE_ARTIFACT_API_BASE_URL=http://localhost:9090 +# Placeholder for runtime injection +ENV VITE_SKYVERN_API_KEY=__SKYVERN_API_KEY_PLACEHOLDER__ -CMD [ "/bin/bash", "/app/entrypoint-skyvernui.sh" ] +# Build at image time +RUN npm run build + +# Use tini as init for proper signal handling and zombie reaping +ENTRYPOINT ["/usr/bin/tini", "--"] +CMD ["/bin/bash", "/app/entrypoint-skyvernui.sh"] diff --git a/entrypoint-skyvernui.sh b/entrypoint-skyvernui.sh index d4225e39..46d7b985 100644 --- a/entrypoint-skyvernui.sh +++ b/entrypoint-skyvernui.sh @@ -2,9 +2,16 @@ set -e -# setting api key -VITE_SKYVERN_API_KEY=$(sed -n 's/.*cred\s*=\s*"\([^"]*\)".*/\1/p' .streamlit/secrets.toml) -export VITE_SKYVERN_API_KEY -npm run start +# Extract API key from secrets file +VITE_SKYVERN_API_KEY=$(sed -n 's/.*cred\s*=\s*"\([^"]*\)".*/\1/p' .streamlit/secrets.toml 2>/dev/null || echo "") +# Inject API key into pre-built JS files (replace placeholder) +if [ -n "$VITE_SKYVERN_API_KEY" ]; then + find /app/dist -name "*.js" -exec sed -i "s/__SKYVERN_API_KEY_PLACEHOLDER__/$VITE_SKYVERN_API_KEY/g" {} \; +fi +# Start the servers (no rebuild needed) +# Tini (configured as ENTRYPOINT) handles signal forwarding and zombie reaping +node localServer.js & +node artifactServer.js & +wait