Files
dostalgia/Dockerfile
T
Hermes Agent 4a25b35667
Build & Deploy / build-and-deploy (push) Failing after 35s
fix: memory bloat from unlimited JVM heap and missing HTTP Range support
Two root causes for memory growing to 1.7GB and never shrinking:

1. No -Xmx limit (Dockerfile): JVM grew its heap without bound after
   processing large uploads and never returned memory to the OS. Now capped
   at 128MB with G1GC periodic GC every 30s to shrink when idle.

2. Broken HTTP Range (StaticResource): The server advertised
   Accept-Ranges: bytes but didn't actually handle Range headers —
   every request sent the entire .jsdos file (up to 1.2GB for GTA).
   The OS cached the full file in page cache, which counts against
   Docker container memory and persists after play stops.

   js-dos v7 loads .jsdos via Range requests (lazy ZIP loading).
   Now properly parses Range: bytes=start-end headers, responds with
   206 Partial Content, and seeks to exact offsets in the file —
   only the requested bytes stream through, keeping page cache minimal.
2026-06-03 15:38:22 +02:00

32 lines
1.3 KiB
Docker

# Dostalgia — Quarkus multi-stage build
# ─── 1. Build frontend ───────────────────────────
FROM node:20-alpine AS frontend
WORKDIR /build
COPY frontend/package.json frontend/package-lock.json ./
RUN npm ci 2>/dev/null || npm install --legacy-peer-deps
COPY frontend/ ./
RUN npm run build
# ─── 2. Build Quarkus app ────────────────────────
FROM maven:3-eclipse-temurin-21-alpine AS build
WORKDIR /build
COPY pom.xml ./
COPY src ./src
# Copy the built frontend into the source tree so maven-resources-plugin picks it up
COPY --from=frontend /build/dist ./frontend/dist/
RUN mvn package -DskipTests -q
# ─── 3. Runtime ──────────────────────────────────
FROM eclipse-temurin:21-jre-alpine
WORKDIR /app
# Quarkus uber-jar layout
COPY --from=build /build/target/quarkus-app/ /app/
EXPOSE 8765
VOLUME /data
ENV DOSTALGIA_DATA_DIR=/data
# Limit JVM heap — the app streams everything (upload/serve) so 128MB is plenty
# G1GC with periodic GC allows heap to shrink when idle
ENTRYPOINT ["java", "-Xmx128m", "-Xms64m", "-XX:+UseG1GC", "-XX:G1PeriodicGCInterval=30000",
"-jar", "quarkus-run.jar"]