fix(build): ensure fresh Flutter build on each deploy
Build and Push / release (push) Successful in 3s
Build and Push / build (push) Successful in 3m1s

- Add flutter clean before build to prevent stale cached artifacts
- Add VERSION build arg for explicit cache busting
- Reorder build steps: clean → pub get → build_runner → health.json → build
- Replace deprecated dart:html with package:web in iframe_view_web.dart
- Add lint ignore to generate_health_json.dart

Fixes issue where Docker layer caching kept old main.dart.js
while regenerating health.json with new version number.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Jeroen Schweitzer
2026-01-04 14:18:01 +01:00
co-authored by Claude Opus 4.5
parent 16bad327f1
commit 8625ac6574
5 changed files with 38 additions and 14 deletions
+13
View File
@@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
## [1.1.0] - 2026-01-04
### Changed
- **Dockerfile rebuild fix**: Added `flutter clean` before build to prevent stale cached artifacts
- VERSION build arg added for explicit cache busting
- Reordered build steps: clean → pub get → build_runner → health.json → flutter build
- Ensures deployed app always matches the version in health.json
### Fixed
- Replaced deprecated `dart:html` with `package:web` in iframe_view_web.dart
- Uses `web.HTMLIFrameElement` instead of `html.IFrameElement`
- Fixes deprecation warnings for Flutter 3.x web builds
## [1.0.12] - 2026-01-04 ## [1.0.12] - 2026-01-04
### Changed ### Changed
+12 -4
View File
@@ -3,16 +3,24 @@ FROM ghcr.io/cirruslabs/flutter:stable AS builder
WORKDIR /app WORKDIR /app
# Copy dependency files first for better caching # VERSION arg busts cache when version changes in pubspec.yaml
COPY pubspec.yaml ./ # Extract version: docker build --build-arg VERSION=$(grep '^version:' pubspec.yaml | cut -d' ' -f2) .
ARG VERSION=0.0.0
RUN echo "Building version: $VERSION"
# Get dependencies (generates pubspec.lock) # Copy dependency files first for better caching
COPY pubspec.yaml pubspec.lock* ./
# Get dependencies
RUN flutter pub get RUN flutter pub get
# Copy the rest of the application # Copy the rest of the application
COPY . . COPY . .
# Generate code with build_runner # Clean any cached build artifacts to ensure fresh build
RUN flutter clean && flutter pub get
# Generate code with build_runner (after clean for fresh generation)
RUN dart run build_runner build --delete-conflicting-outputs RUN dart run build_runner build --delete-conflicting-outputs
# Generate health.json with version info # Generate health.json with version info
@@ -1,8 +1,8 @@
import 'dart:html' as html;
import 'dart:ui_web' as ui_web; import 'dart:ui_web' as ui_web;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
import 'package:web/web.dart' as web;
/// Embedded iframe view for displaying external content (web only). /// Embedded iframe view for displaying external content (web only).
/// ///
@@ -31,7 +31,7 @@ class IframeView extends StatefulWidget {
class _IframeViewState extends State<IframeView> { class _IframeViewState extends State<IframeView> {
late final String _viewType; late final String _viewType;
late html.IFrameElement _iframe; late web.HTMLIFrameElement _iframe;
bool _isLoading = true; bool _isLoading = true;
@override @override
@@ -42,17 +42,18 @@ class _IframeViewState extends State<IframeView> {
} }
void _createIframe() { void _createIframe() {
_iframe = html.IFrameElement() _iframe = web.document.createElement('iframe') as web.HTMLIFrameElement
..src = widget.url ..src = widget.url
..style.border = 'none' ..style.border = 'none'
..style.width = '100%' ..style.width = '100%'
..style.height = '100%' ..style.height = '100%'
..allow = 'fullscreen' ..allow = 'fullscreen';
..onLoad.listen((_) {
if (mounted) { _iframe.onLoad.listen((_) {
setState(() => _isLoading = false); if (mounted) {
} setState(() => _isLoading = false);
}); }
});
// Register the view factory // Register the view factory
ui_web.platformViewRegistry.registerViewFactory( ui_web.platformViewRegistry.registerViewFactory(
+1 -1
View File
@@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts # In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix. # of the product and file versions while build-number is used as the build suffix.
version: 1.0.12+1 version: 1.1.0+1
environment: environment:
sdk: ^3.10.4 sdk: ^3.10.4
+2
View File
@@ -2,6 +2,8 @@
// Generates web/health.json from pubspec.yaml // Generates web/health.json from pubspec.yaml
// Run: dart run tool/generate_health_json.dart // Run: dart run tool/generate_health_json.dart
// ignore_for_file: avoid_print
import 'dart:convert'; import 'dart:convert';
import 'dart:io'; import 'dart:io';