mirror of
https://github.com/R0m1k3/xtremflow.git
synced 2026-10-21 22:18:04 +02:00
build: add verbosity and version tag to diagnose hang
This commit is contained in:
1 parent
3499d6ec8c
commit
1b022ba1d5
1 file changed
+22
-29
+22
-29
@@ -1,45 +1,51 @@
|
|||||||
# Stage 1: Build Environment (Combined for stability and resource management)
|
# Stage 1: Build Environment
|
||||||
FROM ghcr.io/cirruslabs/flutter:stable AS builder
|
FROM ghcr.io/cirruslabs/flutter:stable AS builder
|
||||||
|
|
||||||
USER root
|
USER root
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Version tag to identify the build in logs
|
||||||
|
RUN echo "XTREMFLOW_BUILD_VERSION: 2.0_STABLE_TIMEOUTS"
|
||||||
|
|
||||||
# Optimize DART VM Memory for build
|
# Optimize DART VM Memory for build
|
||||||
ENV DART_VM_OPTIONS="--old_gen_heap_size=16384"
|
ENV DART_VM_OPTIONS="--old_gen_heap_size=16384"
|
||||||
ENV FLUTTER_NO_ANALYTICS=1
|
ENV FLUTTER_NO_ANALYTICS=1
|
||||||
ENV PUB_SUMMARY_ONLY=1
|
ENV PUB_SUMMARY_ONLY=1
|
||||||
|
|
||||||
# 1. Pre-download artifacts (Crucial for Docker stability)
|
# 1. Pre-download artifacts (Force download before build starts)
|
||||||
RUN flutter config --enable-web && flutter precache --web
|
RUN echo "Step 1: Flutter Config and Precache..." && \
|
||||||
|
flutter config --enable-web && \
|
||||||
|
flutter precache --web --verbose
|
||||||
|
|
||||||
# 2. Copy dependency files first for better caching
|
# 2. Copy dependency files first for caching
|
||||||
# Root (Flutter Web)
|
|
||||||
COPY pubspec.yaml ./
|
COPY pubspec.yaml ./
|
||||||
# Server (Dart shelf)
|
|
||||||
COPY bin/pubspec.yaml ./bin/
|
COPY bin/pubspec.yaml ./bin/
|
||||||
|
|
||||||
# 3. Get dependencies sequentially to avoid network/CPU contention
|
# 3. Get dependencies (Verbose to see progress)
|
||||||
RUN flutter pub get && cd bin && dart pub get
|
RUN echo "Step 3: Fetching dependencies..." && \
|
||||||
|
flutter pub get --verbose && \
|
||||||
|
cd bin && dart pub get --verbose
|
||||||
|
|
||||||
# 4. Copy source code
|
# 4. Copy source code
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# 5. Generate code (build_runner)
|
# 5. Generate code (build_runner)
|
||||||
RUN dart run build_runner build --delete-conflicting-outputs
|
RUN echo "Step 5: Code Generation..." && \
|
||||||
|
dart run build_runner build --delete-conflicting-outputs
|
||||||
|
|
||||||
# 6. Build web application (VERBOSE to see progress/blocks)
|
# 6. Build web application (VERBOSE + NO-PUB to prevent network access)
|
||||||
RUN flutter build web --release --base-href="/" --no-tree-shake-icons --verbose
|
RUN echo "Step 6: Building Web Application..." && \
|
||||||
|
flutter build web --release --base-href="/" --no-tree-shake-icons --no-pub --verbose
|
||||||
|
|
||||||
# 7. Compile server to native executable
|
# 7. Compile server to native executable
|
||||||
WORKDIR /app/bin
|
RUN echo "Step 7: Compiling Backend Server..." && \
|
||||||
RUN dart compile exe server.dart -o server
|
cd bin && dart compile exe server.dart -o server
|
||||||
|
|
||||||
# ============================================
|
# ============================================
|
||||||
# Stage 2: Production Runtime (with NVENC support)
|
# Stage 2: Production Runtime
|
||||||
# ============================================
|
# ============================================
|
||||||
FROM debian:stable-slim
|
FROM debian:stable-slim
|
||||||
|
|
||||||
# Install runtime dependencies, tools for fetching FFmpeg, and gosu for privilege dropping
|
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
ca-certificates \
|
ca-certificates \
|
||||||
sqlite3 \
|
sqlite3 \
|
||||||
@@ -50,8 +56,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|||||||
gosu \
|
gosu \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Install FFmpeg with NVIDIA NVENC support from BtbN static builds
|
# FFmpeg with NVENC
|
||||||
# Falls back gracefully to CPU if GPU not available
|
|
||||||
RUN wget -q https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linux64-gpl.tar.xz \
|
RUN wget -q https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linux64-gpl.tar.xz \
|
||||||
&& tar xf ffmpeg-master-latest-linux64-gpl.tar.xz \
|
&& tar xf ffmpeg-master-latest-linux64-gpl.tar.xz \
|
||||||
&& mv ffmpeg-master-latest-linux64-gpl/bin/ffmpeg /usr/local/bin/ \
|
&& mv ffmpeg-master-latest-linux64-gpl/bin/ffmpeg /usr/local/bin/ \
|
||||||
@@ -59,33 +64,21 @@ RUN wget -q https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpe
|
|||||||
&& rm -rf ffmpeg-master-latest-linux64-gpl* \
|
&& rm -rf ffmpeg-master-latest-linux64-gpl* \
|
||||||
&& chmod +x /usr/local/bin/ffmpeg /usr/local/bin/ffprobe
|
&& chmod +x /usr/local/bin/ffmpeg /usr/local/bin/ffprobe
|
||||||
|
|
||||||
# Create non-root user for security
|
|
||||||
RUN groupadd -r xtremuser && useradd -r -g xtremuser -G audio,video xtremuser
|
RUN groupadd -r xtremuser && useradd -r -g xtremuser -G audio,video xtremuser
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Create necessary data directories with correct permissions
|
|
||||||
RUN mkdir -p /app/data /app/web /app/recordings /tmp/xtremflow_streams \
|
RUN mkdir -p /app/data /app/web /app/recordings /tmp/xtremflow_streams \
|
||||||
&& chown -R xtremuser:xtremuser /app /tmp/xtremflow_streams
|
&& chown -R xtremuser:xtremuser /app /tmp/xtremflow_streams
|
||||||
|
|
||||||
# Copy built artifacts from builder stage
|
|
||||||
COPY --from=builder /app/build/web /app/web
|
COPY --from=builder /app/build/web /app/web
|
||||||
COPY --from=builder /app/bin/server /app/server
|
COPY --from=builder /app/bin/server /app/server
|
||||||
|
|
||||||
# Copy entrypoint script and set permissions
|
|
||||||
COPY entrypoint.sh /app/entrypoint.sh
|
COPY entrypoint.sh /app/entrypoint.sh
|
||||||
RUN chmod +x /app/server /app/entrypoint.sh
|
RUN chmod +x /app/server /app/entrypoint.sh
|
||||||
|
|
||||||
# NOTE: We stay as root to allow entrypoint.sh to fix volume permissions
|
|
||||||
# The entrypoint script will drop privileges to xtremuser after fixing permissions
|
|
||||||
|
|
||||||
# Expose port
|
|
||||||
EXPOSE 8089
|
EXPOSE 8089
|
||||||
|
|
||||||
# Healthcheck
|
|
||||||
HEALTHCHECK --interval=30s --timeout=3s \
|
HEALTHCHECK --interval=30s --timeout=3s \
|
||||||
CMD curl -f http://localhost:8089/index.html || exit 1
|
CMD curl -f http://localhost:8089/index.html || exit 1
|
||||||
|
|
||||||
# Use entrypoint to fix permissions then start server as xtremuser
|
|
||||||
ENTRYPOINT ["/app/entrypoint.sh"]
|
ENTRYPOINT ["/app/entrypoint.sh"]
|
||||||
CMD ["/app/server", "--port", "8089", "--path", "/app/web"]
|
CMD ["/app/server", "--port", "8089", "--path", "/app/web"]
|
||||||
Reference in new issue
Block a user