super-productivity/docker-entrypoint.sh
Johannes Millan 2fa804c07a refactor(e2e): migrate to production Dockerfile for E2E tests
Complete E2E Docker migration (Steps 1-3):

1. Add SPA routing support in nginx (try_files directive)
2. Make APP_PORT configurable via environment variable
3. Migrate docker-compose.e2e.yaml from dev server to production build

Changes:
- docker-compose.e2e.yaml: Use production Dockerfile instead of dev server
  - Remove volume mounts (self-contained production build)
  - Add UNSPLASH build args
  - Add WEBDAV_BACKEND environment variable
  - Reduce healthcheck start_period from 120s to 30s (nginx is faster)
- nginx/default.conf.template: Add try_files for SPA routing, use APP_PORT
- docker-entrypoint.sh: Export APP_PORT with default value

Benefits:
- Production build provides more realistic test environment
- Faster startup (30s vs 120s)
- No dependency on local node_modules
- Matches production deployment more closely
2026-01-21 14:30:24 +01:00

38 lines
1.2 KiB
Bash
Executable file

#!/bin/sh
# Set default port if not provided
: "${APP_PORT:=80}"
export APP_PORT
# Generate ./assets/sync-config-default-override.json from environment variables
JSON="{}"
JSON_PATH=./assets/sync-config-default-override.json
if [ -n "${WEBDAV_BASE_URL}" ]; then
JSON=$(echo "$JSON" | jq ".webDav.baseUrl |= \"$WEBDAV_BASE_URL\"")
fi
if [ -n "${WEBDAV_USERNAME}" ]; then
JSON=$(echo "$JSON" | jq ".webDav.userName |= \"$WEBDAV_USERNAME\"")
fi
if [ -n "${WEBDAV_SYNC_FOLDER_PATH}" ]; then
JSON=$(echo "$JSON" | jq ".webDav.syncFolderPath |= \"$WEBDAV_SYNC_FOLDER_PATH\"")
fi
if [ "$JSON" != "{}" ]; then
# Change syncProvider if previous variables are set
JSON=$(echo "$JSON" | jq '.syncProvider |= "WebDAV"')
fi
if [ -n "${SYNC_INTERVAL}" ]; then
JSON=$(echo "$JSON" | jq ".syncInterval |= $(expr $SYNC_INTERVAL \* 60000)")
fi
if [ -n "${IS_COMPRESSION_ENABLED}" ]; then
JSON=$(echo "$JSON" | jq ".isCompressionEnabled |= $IS_COMPRESSION_ENABLED")
fi
if [ -n "${IS_ENCRYPTION_ENABLED}" ]; then
JSON=$(echo "$JSON" | jq ".isEncryptionEnabled |= $IS_ENCRYPTION_ENABLED")
fi
if [ "$JSON" != "{}" ]; then
# Write the resultant json
echo "$JSON" >$JSON_PATH
fi
# go back to nginx's built-in entrypoint script
exec /docker-entrypoint.sh nginx -g "daemon off;"