feat(install): build the Flutter web app in Docker, optional ./install --apk, chosen web password, startup report
This commit is contained in:
@@ -0,0 +1 @@
|
||||
3.44.6
|
||||
@@ -0,0 +1,43 @@
|
||||
# Flutter build images for the Pipelines app. `web` builds the web client the
|
||||
# installer serves; `android` adds a JDK and the Android SDK for the optional
|
||||
# APK. The Flutter version is the app's own pin (app/.flutter-version).
|
||||
#
|
||||
# Built and run by scripts/app_build.py; the container runs as the invoking
|
||||
# user, so the SDK and cache directories are world-writable.
|
||||
FROM debian:bookworm-slim AS web
|
||||
ARG FLUTTER_VERSION
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends ca-certificates curl git unzip xz-utils zip \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
RUN test -n "$FLUTTER_VERSION" \
|
||||
&& git clone --depth 1 --branch "$FLUTTER_VERSION" https://github.com/flutter/flutter.git /opt/flutter \
|
||||
&& git config --system --add safe.directory '*'
|
||||
ENV PATH=/opt/flutter/bin:$PATH \
|
||||
HOME=/home/builder \
|
||||
PUB_CACHE=/home/builder/.pub-cache \
|
||||
FLUTTER_SUPPRESS_ANALYTICS=true
|
||||
RUN mkdir -p /home/builder/.pub-cache \
|
||||
&& flutter --disable-analytics && flutter config --no-cli-animations \
|
||||
&& flutter precache --web --no-android --no-ios --no-linux --no-macos --no-windows --no-fuchsia \
|
||||
&& chmod -R a+rwX /opt/flutter /home/builder
|
||||
COPY build.sh /usr/local/bin/pipelines-app-build
|
||||
WORKDIR /tmp
|
||||
|
||||
FROM web AS android
|
||||
ARG ANDROID_CMDLINE_TOOLS=13114758
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends openjdk-17-jdk-headless \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
ENV ANDROID_HOME=/opt/android-sdk \
|
||||
ANDROID_SDK_ROOT=/opt/android-sdk \
|
||||
GRADLE_USER_HOME=/home/builder/.gradle
|
||||
ENV PATH=$ANDROID_HOME/cmdline-tools/latest/bin:$PATH
|
||||
RUN mkdir -p $ANDROID_HOME/cmdline-tools /home/builder/.gradle /home/builder/.android \
|
||||
&& curl -fsSL -o /tmp/tools.zip "https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_CMDLINE_TOOLS}_latest.zip" \
|
||||
&& unzip -q /tmp/tools.zip -d /tmp/tools && mv /tmp/tools/cmdline-tools $ANDROID_HOME/cmdline-tools/latest \
|
||||
&& rm -rf /tmp/tools /tmp/tools.zip \
|
||||
&& yes | sdkmanager --licenses >/dev/null \
|
||||
&& sdkmanager "platform-tools" >/dev/null \
|
||||
&& flutter config --android-sdk $ANDROID_HOME \
|
||||
&& flutter precache --android \
|
||||
&& chmod -R a+rwX /opt/android-sdk /opt/flutter /home/builder
|
||||
Executable
+27
@@ -0,0 +1,27 @@
|
||||
#!/bin/sh
|
||||
# Builds the app from the read-only source at /src into /out.
|
||||
# Usage: pipelines-app-build web|apk [flutter build arguments...]
|
||||
set -eu
|
||||
kind="$1"
|
||||
shift
|
||||
rm -rf /tmp/work && mkdir -p /tmp/work
|
||||
# A private copy: the host checkout's build outputs and machine paths stay out.
|
||||
(cd /src && tar --exclude=./build --exclude=./.dart_tool --exclude=./android/.gradle \
|
||||
--exclude=./android/local.properties --exclude=./android/app/.cxx --exclude=./ios/Pods \
|
||||
-cf - .) | tar -C /tmp/work -xf -
|
||||
cd /tmp/work
|
||||
flutter pub get
|
||||
case "$kind" in
|
||||
web)
|
||||
flutter build web --release --no-web-resources-cdn "$@"
|
||||
cp -R build/web/. /out/
|
||||
;;
|
||||
apk)
|
||||
flutter build apk --release "$@"
|
||||
cp build/app/outputs/flutter-apk/app-release.apk /out/pipelines.apk
|
||||
;;
|
||||
*)
|
||||
echo "unknown build: $kind" >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
@@ -38,15 +38,29 @@ class AppUpdate {
|
||||
}
|
||||
}
|
||||
|
||||
/// Where a server's app builds live: the preview origin beside it (same host,
|
||||
/// port 8096) under `/updates/`.
|
||||
Uri? updatesBaseFor(Uri endpoint) {
|
||||
/// Where a build set its update feed (`--dart-define=PIPELINES_UPDATES_URL`),
|
||||
/// blank for the default.
|
||||
const configuredUpdatesUrl = String.fromEnvironment('PIPELINES_UPDATES_URL');
|
||||
|
||||
/// The update feed for [endpoint]: `/updates/` on the server's own web origin
|
||||
/// (the installed web proxy serves the APK there), or [configured] when the
|
||||
/// build named another feed.
|
||||
Uri? updatesBaseFor(Uri endpoint, {String configured = configuredUpdatesUrl}) {
|
||||
final override = configured.trim();
|
||||
if (override.isNotEmpty) {
|
||||
final parsed = Uri.tryParse(override);
|
||||
if (parsed != null && parsed.hasScheme && parsed.host.isNotEmpty) {
|
||||
return parsed.path.endsWith('/')
|
||||
? parsed
|
||||
: parsed.replace(path: '${parsed.path}/');
|
||||
}
|
||||
}
|
||||
if (endpoint.host.isEmpty) return null;
|
||||
final secure = endpoint.scheme == 'wss' || endpoint.scheme == 'https';
|
||||
return Uri(
|
||||
scheme: secure ? 'https' : 'http',
|
||||
host: endpoint.host,
|
||||
port: 8096,
|
||||
port: endpoint.hasPort ? endpoint.port : null,
|
||||
path: '/updates/',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,9 +2,29 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/updates/app_updates.dart';
|
||||
|
||||
void main() {
|
||||
test('builds live beside the server, under the preview origin', () {
|
||||
test('builds live on the server\'s own web origin', () {
|
||||
expect(
|
||||
updatesBaseFor(Uri.parse('wss://host.ts.net:8443/connect')).toString(),
|
||||
updatesBaseFor(
|
||||
Uri.parse('wss://host.ts.net:8443/connect'),
|
||||
configured: '',
|
||||
).toString(),
|
||||
'https://host.ts.net:8443/updates/',
|
||||
);
|
||||
expect(
|
||||
updatesBaseFor(
|
||||
Uri.parse('ws://192.168.1.5:8082/connect'),
|
||||
configured: '',
|
||||
).toString(),
|
||||
'http://192.168.1.5:8082/updates/',
|
||||
);
|
||||
});
|
||||
|
||||
test('a build can name another update feed', () {
|
||||
expect(
|
||||
updatesBaseFor(
|
||||
Uri.parse('wss://host.ts.net:8443/connect'),
|
||||
configured: 'https://host.ts.net:8096/updates',
|
||||
).toString(),
|
||||
'https://host.ts.net:8096/updates/',
|
||||
);
|
||||
});
|
||||
|
||||
@@ -18,7 +18,8 @@ export ANDROID_HOME="${ANDROID_HOME:-$HOME/Library/Android/sdk}"
|
||||
code=$(( $(date +%s) / 60 ))
|
||||
name="0.1.$code"
|
||||
"$FLUTTER" build apk --release --build-number="$code" --build-name="$name" \
|
||||
--dart-define=PIPELINES_SERVER_URL="$server"
|
||||
--dart-define=PIPELINES_SERVER_URL="$server" \
|
||||
--dart-define=PIPELINES_UPDATES_URL="${PIPELINES_UPDATES_URL:-https://alans-macbook-pro.tail6bf4dc.ts.net:8096/updates/}"
|
||||
mkdir -p build/updates
|
||||
cp build/app/outputs/flutter-apk/app-release.apk build/updates/pipelines.apk
|
||||
cat > build/updates/version.json <<JSON
|
||||
|
||||
Reference in New Issue
Block a user