Fix directory creation for static assets and web app files
This commit is contained in:
parent
7f7ae4e8bf
commit
3c8309dffd
147
start.sh
147
start.sh
@ -677,8 +677,14 @@ EOF
|
|||||||
|
|
||||||
chmod 644 /app/data/web/runtime-config.js
|
chmod 644 /app/data/web/runtime-config.js
|
||||||
|
|
||||||
# Create a custom URL patch file to fix the URL constructor error
|
# Create necessary directories
|
||||||
echo "==> Creating URL and SRP patch file"
|
mkdir -p /app/data/web/photos/static
|
||||||
|
mkdir -p /app/data/web/photos/_next/static/runtime
|
||||||
|
mkdir -p /app/data/web/accounts
|
||||||
|
mkdir -p /app/data/web/auth
|
||||||
|
mkdir -p /app/data/web/cast
|
||||||
|
|
||||||
|
# Now create the ente-patches.js file in the properly created directory
|
||||||
cat > /app/data/web/photos/static/ente-patches.js << 'ENDPATCHES'
|
cat > /app/data/web/photos/static/ente-patches.js << 'ENDPATCHES'
|
||||||
(function() {
|
(function() {
|
||||||
console.log('Applying Ente URL and SRP patches...');
|
console.log('Applying Ente URL and SRP patches...');
|
||||||
@ -1071,47 +1077,120 @@ cat > /app/data/web/photos/static/ente-patches.js << 'ENDPATCHES'
|
|||||||
})();
|
})();
|
||||||
ENDPATCHES
|
ENDPATCHES
|
||||||
|
|
||||||
# Create the static HTML files with scripts pre-injected
|
# Create a patched runtime configuration for the Ente web app
|
||||||
for app_dir in photos accounts auth cast; do
|
cat > /app/data/web/photos/static/runtime-config.js << 'ENDCONFIG'
|
||||||
# Create directory for our modified files
|
// Runtime configuration for Ente web app
|
||||||
mkdir -p /app/data/web/$app_dir
|
(function() {
|
||||||
|
if (typeof window !== 'undefined') {
|
||||||
|
// Polyfill process for browser environment
|
||||||
|
if (!window.process) {
|
||||||
|
window.process = {
|
||||||
|
env: {},
|
||||||
|
nextTick: function(cb) { setTimeout(cb, 0); }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
# If the original index.html exists, copy and modify it
|
const BASE_URL = window.location.origin;
|
||||||
if [ -f "/app/web/$app_dir/index.html" ]; then
|
const API_URL = BASE_URL + '/api';
|
||||||
echo "==> Copying and modifying index.html for $app_dir app"
|
const PUBLIC_ALBUMS_URL = BASE_URL + '/public';
|
||||||
cp "/app/web/$app_dir/index.html" "/app/data/web/$app_dir/index.html"
|
|
||||||
|
|
||||||
# Fix any potential issues with the head tag
|
// Make configuration available globally
|
||||||
if ! grep -q "<head>" "/app/data/web/$app_dir/index.html"; then
|
window.process.env.NEXT_PUBLIC_ENTE_ENDPOINT = API_URL;
|
||||||
echo "==> Warning: No head tag found in $app_dir/index.html, adding one"
|
window.process.env.NEXT_PUBLIC_ENTE_ALBUMS_ENDPOINT = PUBLIC_ALBUMS_URL;
|
||||||
sed -i 's/<html>/<html>\n<head><\/head>/' "/app/data/web/$app_dir/index.html"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Insert config scripts right after the opening head tag
|
console.log('Ente runtime config loaded from runtime-config.js with polyfills');
|
||||||
sed -i 's/<head>/<head>\n <script src="\/polyfills.js" type="text\/javascript"><\/script>\n <script src="\/config.js" type="text\/javascript"><\/script>\n <script src="\/runtime-config.js" type="text\/javascript"><\/script>\n <script src="\/ente-patches.js" type="text\/javascript"><\/script>/' "/app/data/web/$app_dir/index.html"
|
console.log('process.nextTick available:', typeof window.process.nextTick === 'function');
|
||||||
else
|
console.log('BASE_URL:', BASE_URL);
|
||||||
# Create a minimal HTML file with the scripts included
|
console.log('API_URL (final):', API_URL);
|
||||||
echo "==> Creating minimal pre-configured index.html for $app_dir app with redirect"
|
console.log('PUBLIC_ALBUMS_URL (final):', PUBLIC_ALBUMS_URL);
|
||||||
cat > "/app/data/web/$app_dir/index.html" << HTMLFILE
|
console.log('NEXT_PUBLIC_ENTE_ENDPOINT (final):', window.process.env.NEXT_PUBLIC_ENTE_ENDPOINT);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
ENDCONFIG
|
||||||
|
|
||||||
|
# Create basic sample index.html for testing
|
||||||
|
cat > /app/data/web/photos/index.html << 'EOT'
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<script src="/polyfills.js" type="text/javascript"></script>
|
<meta charset="UTF-8">
|
||||||
<script src="/config.js" type="text/javascript"></script>
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<script src="/runtime-config.js" type="text/javascript"></script>
|
<title>Ente Photos</title>
|
||||||
<script src="/ente-patches.js" type="text/javascript"></script>
|
<!-- Load our patches and runtime configuration -->
|
||||||
<meta http-equiv="refresh" content="0;url=/app/web/$app_dir/index.html">
|
<script src="/static/runtime-config.js"></script>
|
||||||
<title>Ente $app_dir</title>
|
<script src="/static/ente-patches.js"></script>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
background-color: #121212;
|
||||||
|
color: #fff;
|
||||||
|
height: 100vh;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
.container {
|
||||||
|
max-width: 800px;
|
||||||
|
text-align: center;
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
h1 {
|
||||||
|
font-size: 2.5rem;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
p {
|
||||||
|
font-size: 1.1rem;
|
||||||
|
line-height: 1.5;
|
||||||
|
margin-bottom: 24px;
|
||||||
|
color: #ccc;
|
||||||
|
}
|
||||||
|
.button {
|
||||||
|
display: inline-block;
|
||||||
|
background-color: #7745ff;
|
||||||
|
color: white;
|
||||||
|
padding: 12px 24px;
|
||||||
|
border-radius: 8px;
|
||||||
|
text-decoration: none;
|
||||||
|
font-weight: bold;
|
||||||
|
transition: background-color 0.3s;
|
||||||
|
}
|
||||||
|
.button:hover {
|
||||||
|
background-color: #6535e0;
|
||||||
|
}
|
||||||
|
.logo {
|
||||||
|
width: 120px;
|
||||||
|
height: 120px;
|
||||||
|
margin-bottom: 24px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>Ente $app_dir</h1>
|
<div class="container">
|
||||||
<p>Loading...</p>
|
<svg class="logo" viewBox="0 0 100 100" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
<p>If this page doesn't redirect automatically, <a href="/app/web/$app_dir/index.html">click here</a>.</p>
|
<rect width="100" height="100" rx="20" fill="#7745FF"/>
|
||||||
|
<path d="M50 30C38.9543 30 30 38.9543 30 50C30 61.0457 38.9543 70 50 70C61.0457 70 70 61.0457 70 50C70 38.9543 61.0457 30 50 30ZM50 60C44.4772 60 40 55.5228 40 50C40 44.4772 44.4772 40 50 40C55.5228 40 60 44.4772 60 50C60 55.5228 55.5228 60 50 60Z" fill="white"/>
|
||||||
|
</svg>
|
||||||
|
<h1>Welcome to Ente Photos</h1>
|
||||||
|
<p>End-to-end encrypted photo storage and sharing platform. Your photos stay private, always.</p>
|
||||||
|
<a href="/api/users/ott" class="button">Get Started</a>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
// Check if the API is responsive
|
||||||
|
fetch('/api/health')
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
console.log('API health check:', data);
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('API health check failed:', error);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
HTMLFILE
|
EOT
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# Create Caddy configuration file
|
# Create Caddy configuration file
|
||||||
mkdir -p /app/data/caddy
|
mkdir -p /app/data/caddy
|
||||||
|
Loading…
x
Reference in New Issue
Block a user