mirror of
https://github.com/allankoechke/mantisbase-demo.git
synced 2026-11-29 09:16:54 +00:00
feat: pulled lated mb web interface + added analytics injection
This commit is contained in:
@@ -12,7 +12,7 @@ RUN rm -rf /app/out
|
||||
RUN npm run build
|
||||
|
||||
# Stage 2: mantisbase image + built UI in /mb/public + default DB in /mb/data-default
|
||||
FROM allankoech/mantisbase:latest
|
||||
FROM allankoech/mantisbase:beta
|
||||
WORKDIR /mb
|
||||
|
||||
ENV NEXT_PUBLIC_BASE_PATH=""
|
||||
@@ -23,5 +23,10 @@ COPY --from=ui-builder /app/out/ ./public/
|
||||
COPY db/data ./data-default/
|
||||
COPY scripts/docker-entrypoint.sh /entrypoint.sh
|
||||
|
||||
# Inject analytics script
|
||||
COPY inject-analytics.sh /inject-analytics.sh
|
||||
RUN chmod +x /inject-analytics.sh
|
||||
RUN /inject-analytics.sh /mb/public
|
||||
|
||||
EXPOSE 80
|
||||
ENTRYPOINT ["/bin/sh", "/entrypoint.sh"]
|
||||
|
||||
Binary file not shown.
@@ -10,3 +10,11 @@ services:
|
||||
- ./db/data:/db-default:ro
|
||||
- ./scripts/docker-entrypoint.sh:/entrypoint.sh:ro
|
||||
entrypoint: ["/bin/sh", "/entrypoint.sh"]
|
||||
environment:
|
||||
- MB_JWT_SECRET=${MB_JWT_SECRET}
|
||||
- MB_DISABLE_FILE_UPLOADS=true
|
||||
- MB_OAUTH_ENCRYPTION_KEY=${MB_OAUTH_ENCRYPTION_KEY}
|
||||
- MB_REALTIME_SSE_KEY=${MB_REALTIME_SSE_KEY}
|
||||
- MB_REALTIME_WS=${MB_REALTIME_WS}
|
||||
- MB_DISABLE_ADMIN_MUTATIONS=${MB_DISABLE_ADMIN_MUTATIONS}
|
||||
- MB_DISABLE_CONFIG_MUTATIONS=${MB_DISABLE_CONFIG_MUTATIONS}
|
||||
|
||||
46
inject-analytics.sh
Normal file
46
inject-analytics.sh
Normal file
@@ -0,0 +1,46 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -eu
|
||||
|
||||
OUTPUT_DIR="${1:-./out}"
|
||||
ANALYTICS_SCRIPT="${ANALYTICS_SCRIPT:-<script defer data-domain="demo.mantisbase.com" src="https://analytics.codeart.co.ke/js/script.file-downloads.hash.outbound-links.pageview-props.revenue.tagged-events.js"></script>
|
||||
<script>window.plausible = window.plausible || function() { (window.plausible.q = window.plausible.q || []).push(arguments) }</script>
|
||||
}"
|
||||
|
||||
if [ ! -d "$OUTPUT_DIR" ]; then
|
||||
echo "Error: output directory does not exist: $OUTPUT_DIR" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
find "$OUTPUT_DIR" -type f -name '*.html' -print0 |
|
||||
while IFS= read -r -d '' file; do
|
||||
if grep -qF "$ANALYTICS_SCRIPT" "$file"; then
|
||||
echo "Skipping: $file"
|
||||
continue
|
||||
fi
|
||||
|
||||
if ! grep -qi '</head>' "$file"; then
|
||||
echo "Warning: no </head> found: $file" >&2
|
||||
continue
|
||||
fi
|
||||
|
||||
tmp="${file}.tmp"
|
||||
|
||||
awk -v script="$ANALYTICS_SCRIPT" '
|
||||
BEGIN {
|
||||
IGNORECASE = 1
|
||||
injected = 0
|
||||
}
|
||||
|
||||
!injected && /<\/head>/ {
|
||||
sub(/<\/head>/, script "</head>")
|
||||
injected = 1
|
||||
}
|
||||
|
||||
{ print }
|
||||
' "$file" > "$tmp"
|
||||
|
||||
mv "$tmp" "$file"
|
||||
|
||||
echo "Injected: $file"
|
||||
done
|
||||
2
mb
2
mb
Submodule mb updated: 2630c1fa22...3b227cb720
Reference in New Issue
Block a user