mirror of
https://github.com/Sevi-py/tnyr.me.git
synced 2026-04-03 03:00:21 -04:00
fix docker deployment
This commit is contained in:
@@ -17,17 +17,22 @@ if [ -z "$PUBLIC_URL" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DOMAIN="$(python - <<'PY'
|
||||
INFO="$(python - <<'PY'
|
||||
import os
|
||||
from urllib.parse import urlparse
|
||||
u = os.environ.get("TNYR_PUBLIC_URL","").strip()
|
||||
p = urlparse(u)
|
||||
if p.scheme not in ("http","https") or not p.netloc:
|
||||
raise SystemExit("Invalid TNYR_PUBLIC_URL (must be http(s)://host[:port])")
|
||||
print(f"{p.scheme}://{p.netloc}")
|
||||
print(p.netloc)
|
||||
PY
|
||||
)"
|
||||
|
||||
read -r NORMALIZED_PUBLIC_URL DOMAIN <<EOF
|
||||
$INFO
|
||||
EOF
|
||||
|
||||
if [ -n "${DB_PATH:-}" ]; then
|
||||
DB_DIR="$(dirname "$DB_PATH")"
|
||||
mkdir -p "$DB_DIR" || true
|
||||
@@ -37,11 +42,13 @@ mkdir -p /data || true
|
||||
|
||||
if [ -d "$DIST_DIR" ]; then
|
||||
if [ -n "$DOMAIN" ]; then
|
||||
echo "Applying public URL + domain to static files: $PUBLIC_URL ($DOMAIN)"
|
||||
SED_PUBLIC_URL="$(printf '%s' "$PUBLIC_URL" | sed 's/[\/&]/\\&/g')"
|
||||
echo "Applying public URL + domain to static files: $NORMALIZED_PUBLIC_URL ($DOMAIN)"
|
||||
SED_PUBLIC_URL="$(printf '%s' "$NORMALIZED_PUBLIC_URL" | sed 's/[\/&]/\\&/g')"
|
||||
SED_DOMAIN="$(printf '%s' "$DOMAIN" | sed 's/[\/&]/\\&/g')"
|
||||
find "$DIST_DIR" -type f \( -name "*.html" -o -name "*.xml" -o -name "*.json" -o -name "*.webmanifest" \) -print0 \
|
||||
| xargs -0 -r sed -i \
|
||||
-e "s/__TNYR_PUBLIC_URL__/$SED_PUBLIC_URL/g" \
|
||||
-e "s/__TNYR_DOMAIN__/$SED_DOMAIN/g" \
|
||||
-e "s/%VITE_PUBLIC_URL%/$SED_PUBLIC_URL/g" \
|
||||
-e "s/%VITE_DOMAIN%/$SED_DOMAIN/g"
|
||||
else
|
||||
|
||||
@@ -6,32 +6,32 @@
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon/favicon.svg" />
|
||||
<link rel="shortcut icon" href="/favicon/favicon.ico" />
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="/favicon/apple-touch-icon.png" />
|
||||
<meta name="apple-mobile-web-app-title" content="%VITE_DOMAIN%" />
|
||||
<meta name="apple-mobile-web-app-title" content="__TNYR_DOMAIN__" />
|
||||
<link rel="manifest" href="/favicon/site.webmanifest" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="An easy to use end-to-end encrypted URL shortener. tnyr.me is privacy friendly and does not track you or store cookies" />
|
||||
<link rel="canonical" href="%VITE_PUBLIC_URL%" />
|
||||
<link rel="canonical" href="__TNYR_PUBLIC_URL__" />
|
||||
|
||||
<meta property="og:title" content="TNYR - Privacy friendly URL shortener" />
|
||||
<meta property="og:site_name" content="%VITE_DOMAIN%">
|
||||
<meta property="og:url" content="%VITE_PUBLIC_URL%">
|
||||
<meta property="og:site_name" content="__TNYR_DOMAIN__">
|
||||
<meta property="og:url" content="__TNYR_PUBLIC_URL__">
|
||||
<meta property="og:description" content="A self encrypted url shortener that puts your privacy first, while being easy to use. tnyr.me doesn't track users, store cookies or log your requests.">
|
||||
<meta property="og:type" content="website">
|
||||
<meta property="og:image" content="%VITE_PUBLIC_URL%/meta/logo.png">
|
||||
<meta property="og:image" content="__TNYR_PUBLIC_URL__/meta/logo.png">
|
||||
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context": "https://schema.org",
|
||||
"@type": "WebSite",
|
||||
"name": "TNYR",
|
||||
"url": "%VITE_PUBLIC_URL%",
|
||||
"url": "__TNYR_PUBLIC_URL__",
|
||||
"description": "A self encrypted url shortener that puts your privacy first, while being easy to use. tnyr.me doesn't track users, store cookies or log your requests."
|
||||
}
|
||||
</script>
|
||||
|
||||
<script>
|
||||
window.__TNYR_PUBLIC_URL__ = "%VITE_PUBLIC_URL%";
|
||||
window.__TNYR_DOMAIN__ = "%VITE_DOMAIN%";
|
||||
window.__TNYR_PUBLIC_URL__ = "__TNYR_PUBLIC_URL__";
|
||||
window.__TNYR_DOMAIN__ = "__TNYR_DOMAIN__";
|
||||
</script>
|
||||
|
||||
<title>tnyr.me - Privacy friendly URL shortener</title>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "%VITE_DOMAIN%",
|
||||
"short_name": "%VITE_DOMAIN%",
|
||||
"name": "__TNYR_DOMAIN__",
|
||||
"short_name": "__TNYR_DOMAIN__",
|
||||
"icons": [
|
||||
{
|
||||
"src": "/assets/favicon/web-app-manifest-192x192.png",
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
|
||||
|
||||
<url>
|
||||
<loc>%VITE_PUBLIC_URL%/</loc>
|
||||
<loc>__TNYR_PUBLIC_URL__/</loc>
|
||||
</url>
|
||||
|
||||
|
||||
|
||||
@@ -34,14 +34,14 @@ const ALLOWED_CHARS = 'abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ12345678
|
||||
const getConfiguredDomain = () => {
|
||||
if (typeof window === 'undefined') return '';
|
||||
const v = (window as any).__TNYR_DOMAIN__;
|
||||
if (typeof v === 'string' && v && v !== '%VITE_DOMAIN%') return v;
|
||||
if (typeof v === 'string' && v && v !== '%VITE_DOMAIN%' && v !== '__TNYR_DOMAIN__') return v;
|
||||
return '';
|
||||
};
|
||||
|
||||
const getConfiguredPublicUrl = () => {
|
||||
if (typeof window === 'undefined') return '';
|
||||
const v = (window as any).__TNYR_PUBLIC_URL__;
|
||||
if (typeof v === 'string' && v && v !== '%VITE_PUBLIC_URL%') return v.replace(/\/+$/, '');
|
||||
if (typeof v === 'string' && v && v !== '%VITE_PUBLIC_URL%' && v !== '__TNYR_PUBLIC_URL__') return v.replace(/\/+$/, '');
|
||||
return '';
|
||||
};
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ export default defineConfig({
|
||||
},
|
||||
},
|
||||
build: {
|
||||
outDir: path.resolve(__dirname, "../backend/dist"),
|
||||
outDir: path.resolve(__dirname, "./dist"),
|
||||
emptyOutDir: true,
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user