mirror of
https://github.com/R0m1k3/xtremflow.git
synced 2026-10-22 06:28:04 +02:00
build: optimize docker caching strategy to avoid redundant installs
This commit is contained in:
1 parent
36a74d9e97
commit
8098e024a9
1 file changed
+17
-27
+17
-27
@@ -1,45 +1,35 @@
|
|||||||
# Stage 1: Build Environment
|
# Stage 1: Build Environment (Optimized for Docker Caching)
|
||||||
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
|
# Optimize DART VM Memory
|
||||||
RUN echo "XTREMFLOW_BUILD_VERSION: 2.0_STABLE_TIMEOUTS"
|
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
# 1. Pre-download artifacts (Force download before build starts)
|
# 1. System Config & Precache (RARELY CHANGES)
|
||||||
RUN echo "Step 1: Flutter Config and Precache..." && \
|
RUN flutter config --enable-web && flutter precache --web
|
||||||
flutter config --enable-web && \
|
|
||||||
flutter precache --web --verbose
|
|
||||||
|
|
||||||
# 2. Copy dependency files first for caching
|
# 2. Dependency Resolution (ONLY UPDATES IF PUBSPEC CHANGES)
|
||||||
COPY pubspec.yaml ./
|
COPY pubspec.yaml ./
|
||||||
COPY bin/pubspec.yaml ./bin/
|
COPY bin/pubspec.yaml ./bin/
|
||||||
|
# Note: No .lock files found locally, so we fetch fresh ones here
|
||||||
|
RUN flutter pub get && cd bin && dart pub get
|
||||||
|
|
||||||
# 3. Get dependencies (Verbose to see progress)
|
# 3. Source Code Copy (CHANGES OFTEN)
|
||||||
RUN echo "Step 3: Fetching dependencies..." && \
|
# Everything except what's in .dockerignore (built-in protection)
|
||||||
flutter pub get --verbose && \
|
|
||||||
cd bin && dart pub get --verbose
|
|
||||||
|
|
||||||
# 4. Copy source code
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# 5. Generate code (build_runner)
|
# 4. Code Generation
|
||||||
RUN echo "Step 5: Code Generation..." && \
|
RUN dart run build_runner build --delete-conflicting-outputs
|
||||||
dart run build_runner build --delete-conflicting-outputs
|
|
||||||
|
|
||||||
# 6. Build web application (VERBOSE + NO-PUB to prevent network access)
|
# 5. Compilation (SLOWEST STEP - INEVITABLE)
|
||||||
RUN echo "Step 6: Building Web Application..." && \
|
# This step MUST run if you modified any Dart file.
|
||||||
flutter build web --release --base-href="/" --no-tree-shake-icons --no-pub --verbose
|
RUN flutter build web --release --base-href="/" --no-tree-shake-icons --no-pub
|
||||||
|
|
||||||
# 7. Compile server to native executable
|
# 6. Native Server Compilation
|
||||||
RUN echo "Step 7: Compiling Backend Server..." && \
|
RUN cd bin && dart compile exe server.dart -o server
|
||||||
cd bin && dart compile exe server.dart -o server
|
|
||||||
|
|
||||||
# ============================================
|
# ============================================
|
||||||
# Stage 2: Production Runtime
|
# Stage 2: Production Runtime
|
||||||
@@ -56,7 +46,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/*
|
||||||
|
|
||||||
# FFmpeg with NVENC
|
# FFmpeg with NVENC (cached unless this RUN changes)
|
||||||
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/ \
|
||||||
|
|||||||
Reference in new issue
Block a user