Add base kubernetes support 5

This commit is contained in:
Urtzi Alfaro
2025-09-27 22:55:42 +02:00
parent f246381d34
commit b95ecf1c53
9 changed files with 274 additions and 43 deletions

View File

@@ -35,35 +35,8 @@ COPY nginx.conf /etc/nginx/conf.d/
# Copy built application from builder stage
COPY --from=builder /app/dist /usr/share/nginx/html
# Create a script to substitute environment variables at runtime
COPY <<'EOF' /docker-entrypoint.d/30-substitute-env.sh
#!/bin/sh
set -e
# Handle VITE_API_URL specially to preserve empty values
# If VITE_API_URL is unset, use default; if empty, preserve empty; otherwise use value
if [ -z "${VITE_API_URL+x}" ]; then
export VITE_API_URL="/api"
elif [ -z "$VITE_API_URL" ]; then
# If VITE_API_URL is explicitly set to empty string, use relative API path
export VITE_API_URL="/api"
fi
# Default values for other environment variables
export VITE_APP_TITLE=${VITE_APP_TITLE:-"PanIA Dashboard"}
export VITE_APP_VERSION=${VITE_APP_VERSION:-"1.0.0"}
# Create a runtime configuration file that can be loaded by the frontend
cat > /usr/share/nginx/html/runtime-config.js << EOL
window.__RUNTIME_CONFIG__ = {
VITE_API_URL: '${VITE_API_URL}',
VITE_APP_TITLE: '${VITE_APP_TITLE}',
VITE_APP_VERSION: '${VITE_APP_VERSION}'
};
EOL
echo "Runtime configuration created with API URL: ${VITE_API_URL}"
EOF
# Copy and setup environment substitution script
COPY substitute-env.sh /docker-entrypoint.d/30-substitute-env.sh
# Make the script executable
RUN chmod +x /docker-entrypoint.d/30-substitute-env.sh

View File

@@ -56,7 +56,7 @@ class ApiClient {
config: AxiosRequestConfig;
}> = [];
constructor(baseURL: string = getApiUrl() + '/api/v1') {
constructor(baseURL: string = getApiUrl() + '/v1') {
this.baseURL = baseURL;
this.client = axios.create({

View File

@@ -0,0 +1,26 @@
#!/bin/sh
set -e
# Handle VITE_API_URL specially to preserve empty values
# If VITE_API_URL is unset, use default; if empty, preserve empty; otherwise use value
if [ -z "${VITE_API_URL+x}" ]; then
export VITE_API_URL="/api"
elif [ -z "$VITE_API_URL" ]; then
# If VITE_API_URL is explicitly set to empty string, use relative API path
export VITE_API_URL="/api"
fi
# Default values for other environment variables
export VITE_APP_TITLE=${VITE_APP_TITLE:-"PanIA Dashboard"}
export VITE_APP_VERSION=${VITE_APP_VERSION:-"1.0.0"}
# Create a runtime configuration file that can be loaded by the frontend
cat > /usr/share/nginx/html/runtime-config.js << EOL
window.__RUNTIME_CONFIG__ = {
VITE_API_URL: '${VITE_API_URL}',
VITE_APP_TITLE: '${VITE_APP_TITLE}',
VITE_APP_VERSION: '${VITE_APP_VERSION}'
};
EOL
echo "Runtime configuration created with API URL: ${VITE_API_URL}"