Dockerfile tweaks

This commit is contained in:
ponzischeme89
2026-01-18 00:48:29 +13:00
parent cd62197b3b
commit 96b45ed05e
3 changed files with 60 additions and 53 deletions
+40 -38
View File
@@ -3,76 +3,78 @@ FROM --platform=$BUILDPLATFORM node:20-alpine AS frontend-builder
WORKDIR /app/frontend WORKDIR /app/frontend
# Copy package files and install dependencies
COPY frontend/package*.json ./ COPY frontend/package*.json ./
RUN npm ci RUN npm ci
# Copy frontend source and build
COPY frontend/ ./ COPY frontend/ ./
RUN npm run build RUN npm run build
# Stage 2: Python backend with built frontend # Stage 2: Python backend with built frontend
FROM --platform=$TARGETPLATFORM python:3.11-slim FROM --platform=$TARGETPLATFORM python:3.11-slim
WORKDIR /app WORKDIR /app
# Install system dependencies # System dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \ RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \ gcc \
gosu \ gosu \
&& rm -rf /var/lib/apt/lists/* passwd \
&& rm -rf /var/lib/apt/lists/*
# Copy and install Python dependencies # Python dependencies
COPY server/requirements.txt ./ COPY server/requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt RUN pip install --no-cache-dir -r requirements.txt
# Copy server code # App code
COPY server/ ./ COPY server/ ./
# Copy built frontend from stage 1 # Frontend dist -> static folder
COPY --from=frontend-builder /app/frontend/dist ./static COPY --from=frontend-builder /app/frontend/dist ./static
# Create data directories for SQLite database and user config # Data dirs
RUN mkdir -p /app/data /config /media RUN mkdir -p /app/data /config /media
# Environment variables # Default env — but PUID/PGID now OPTIONAL
ENV FLASK_APP=app.py ENV FLASK_APP=app.py \
ENV FLASK_ENV=production FLASK_ENV=production \
ENV PYTHONUNBUFFERED=1 PYTHONUNBUFFERED=1 \
ENV PUID= PORT=5000 \
ENV PGID= GUNICORN_WORKERS=1 \
ENV GUNICORN_WORKERS=1 GUNICORN_THREADS=2 \
ENV GUNICORN_THREADS=2 GUNICORN_TIMEOUT=120
ENV GUNICORN_TIMEOUT=120
# Expose port
EXPOSE 5000 EXPOSE 5000
# Entrypoint to handle optional PUID/PGID and low-memory defaults
# ENTRYPOINT — now *does NOT require* PUID/PGID
# Safely strips quotes; only uses them if they exist and are valid numbers
RUN printf '%s\n' \ RUN printf '%s\n' \
'#!/bin/sh' \ '#!/bin/sh' \
'set -e' \ 'set -e' \
'' \ '' \
'echo \"Sublogue - Docker image starting\"' \ 'echo "Sublogue - Docker image starting"' \
'echo \"Sublogue - Initializing container\"' \ 'echo "Sublogue - Initializing container"' \
'if [ -n \"$PUID\" ] && [ -n \"$PGID\" ]; then' \
' echo \"Sublogue - Running with PUID=$PUID PGID=$PGID\"' \
' if ! getent group \"$PGID\" >/dev/null 2>&1; then' \
' groupadd -g \"$PGID\" appgroup' \
' fi' \
' if ! id -u \"$PUID\" >/dev/null 2>&1; then' \
' useradd -u \"$PUID\" -g \"$PGID\" -m appuser' \
' fi' \
' chown -R \"$PUID\":\"$PGID\" /config /app/data /media 2>/dev/null || true' \
' exec gosu \"$PUID\":\"$PGID\" \"$@\"' \
'fi' \
'echo \"Sublogue - Running as root (PUID/PGID not set)\"' \
'' \ '' \
'exec \"$@\"' \ '# Clean quotes if Komodo/Portainer injects them' \
'PUID_CLEAN=$(echo "$PUID" | tr -d "\"")' \
'PGID_CLEAN=$(echo "$PGID" | tr -d "\"")' \
'' \
'# Only run UID/GID logic if BOTH are valid integers' \
'if [ -n "$PUID_CLEAN" ] && [ -n "$PGID_CLEAN" ] && [ "$PUID_CLEAN" -eq "$PUID_CLEAN" ] 2>/dev/null && [ "$PGID_CLEAN" -eq "$PGID_CLEAN" ] 2>/dev/null; then' \
' echo "Sublogue - Running with PUID=$PUID_CLEAN PGID=$PGID_CLEAN"' \
' getent group "$PGID_CLEAN" >/dev/null 2>&1 || groupadd -g "$PGID_CLEAN" appgroup' \
' id -u "$PUID_CLEAN" >/dev/null 2>&1 || useradd -u "$PUID_CLEAN" -g "$PGID_CLEAN" -m appuser' \
' chown -R "$PUID_CLEAN:$PGID_CLEAN" /config /app/data /media || true' \
' exec gosu "$PUID_CLEAN:$PGID_CLEAN" "$@"' \
'else' \
' echo "Sublogue - Running as root (no valid PUID/PGID provided)"' \
'fi' \
'' \
'exec "$@"' \
> /usr/local/bin/entrypoint.sh \ > /usr/local/bin/entrypoint.sh \
&& chmod +x /usr/local/bin/entrypoint.sh && chmod +x /usr/local/bin/entrypoint.sh
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
# Run with Gunicorn (tuned for low-memory hosts by default) CMD ["sh", "-c", "echo \"Sublogue - Starting web server on port ${PORT}\"; gunicorn --bind 0.0.0.0:${PORT} --workers ${GUNICORN_WORKERS} --threads ${GUNICORN_THREADS} --timeout ${GUNICORN_TIMEOUT} app:app"]
CMD ["sh", "-c", "gunicorn --bind 0.0.0.0:5000 --workers ${GUNICORN_WORKERS} --threads ${GUNICORN_THREADS} --timeout ${GUNICORN_TIMEOUT} app:app"]
Binary file not shown.

After

Width:  |  Height:  |  Size: 190 KiB

+20 -15
View File
@@ -15,7 +15,7 @@
History, History,
} from "lucide-svelte"; } from "lucide-svelte";
import ThemeSelector from "./ThemeSelector.svelte"; import ThemeSelector from "./ThemeSelector.svelte";
import sublogueLogo from "../assets/logo.png"; import sublogueLogo from "../assets/sublogue_v2.png";
export let currentView = "scanner"; export let currentView = "scanner";
export let onNavigate; export let onNavigate;
@@ -36,21 +36,26 @@
<div <div
class={`relative flex items-center gap-3 py-5 ${collapsed ? "px-2" : "px-4"}`} class={`relative flex items-center gap-3 py-5 ${collapsed ? "px-2" : "px-4"}`}
> >
<div {#if collapsed}
class="relative flex h-9 w-9 items-center justify-center rounded-lg border border-white/10 bg-black/40 overflow-hidden" <div
> class="relative flex h-9 w-9 items-center justify-center rounded-lg border border-white/10 bg-black/40 overflow-hidden"
<span class="absolute inset-0 rounded-lg bg-blue-500/10 blur-md"></span> >
<span class="absolute inset-0 rounded-lg bg-blue-500/10 blur-md"
></span>
<img <img
src={sublogueLogo} src={sublogueLogo}
alt="Sublogue" alt="Sublogue"
class="relative h-full w-full object-cover" class="relative h-full w-full object-cover"
/> />
</div> </div>
{:else}
{#if !collapsed} <div class="flex items-center -ml-6">
<div> <img
<div class="text-[15pt] font-bold tracking-tight">Sublogue</div> src={sublogueLogo}
alt="Sublogue"
class="h-9 w-auto max-w-[220px] object-contain"
/>
</div> </div>
{/if} {/if}
<button <button