diff --git a/Dockerfile b/Dockerfile index 52d2104..e0dc828 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,7 @@ RUN rm -rf /usr/share/nginx/html/* COPY nginx.conf /etc/nginx/conf.d/default.conf # Publish web assets only. Backend source, tests and local configuration are not static downloads. -COPY index.html app.js workspace.js style.css sw.js manifest.json gt_full_catalog.json /usr/share/nginx/html/ +COPY index.html app.js workspace.js style.css sw.js manifest.json favicon.svg gt_full_catalog.json /usr/share/nginx/html/ COPY assets/ /usr/share/nginx/html/assets/ COPY data/ /usr/share/nginx/html/data/ diff --git a/Dockerfile.api b/Dockerfile.api index 7dcc75d..4c32727 100644 --- a/Dockerfile.api +++ b/Dockerfile.api @@ -5,7 +5,7 @@ ENV NODE_ENV=production PORT=3000 STUDIO_DATA_DIR=/data/studio COPY package.json package-lock.json ./ RUN npm ci --omit=dev --ignore-scripts --no-fund --no-audit COPY server/ ./server/ -COPY index.html app.js workspace.js style.css sw.js manifest.json ./public/ +COPY index.html app.js workspace.js style.css sw.js manifest.json favicon.svg ./public/ COPY assets/ ./public/assets/ RUN mkdir -p /data/studio && chown -R node:node /app /data/studio USER node diff --git a/favicon.svg b/favicon.svg new file mode 100644 index 0000000..ca4556b --- /dev/null +++ b/favicon.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/server/static.cjs b/server/static.cjs index 80318a5..35c8814 100644 --- a/server/static.cjs +++ b/server/static.cjs @@ -4,7 +4,7 @@ const { createHash } = require('node:crypto'); const { gzipSync } = require('node:zlib'); const MIME = { '.html': 'text/html; charset=utf-8', '.js': 'application/javascript; charset=utf-8', '.css': 'text/css; charset=utf-8', '.json': 'application/json; charset=utf-8', '.png': 'image/png', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg', '.webp': 'image/webp', '.svg': 'image/svg+xml', '.ico': 'image/x-icon', '.woff': 'font/woff', '.woff2': 'font/woff2' }; -const ROOT_FILES = new Set(['index.html', 'app.js', 'workspace.js', 'style.css', 'sw.js', 'manifest.json']); +const ROOT_FILES = new Set(['index.html', 'app.js', 'workspace.js', 'style.css', 'sw.js', 'manifest.json', 'favicon.svg']); function createStaticHandler(publicDirectory, { maxCacheBytes = 16 * 1024 * 1024 } = {}) { const root = path.resolve(publicDirectory), cache = new Map(); @@ -18,7 +18,7 @@ function createStaticHandler(publicDirectory, { maxCacheBytes = 16 * 1024 * 1024 let pathname; try { pathname = decodeURIComponent(request.url.split('?')[0]); } catch { return missing(response); } if (pathname.includes('\\') || pathname.includes('\0') || pathname.split('/').some(p => p.startsWith('.'))) return missing(response); - let relative = pathname === '/' ? 'index.html' : pathname.replace(/^\/+/, ''); + let relative = pathname === '/' ? 'index.html' : (pathname === '/favicon.ico' ? 'favicon.svg' : pathname.replace(/^\/+/, '')); const asset = relative.startsWith('assets/') && MIME[path.extname(relative).toLowerCase()]; if (!ROOT_FILES.has(relative) && !asset) { if (!path.extname(relative) && !/^(?:server|docs|test|data|node_modules)(?:\/|$)/.test(relative) && String(request.headers.accept || '').includes('text/html')) relative = 'index.html';