62 lines
1.7 KiB
Docker
62 lines
1.7 KiB
Docker
# TODO: support multi-arch building
|
|
# TODO: https://docs.docker.com/reference/build-checks/from-platform-flag-const-disallowed/
|
|
|
|
# Multi-arch Dockerfile for building Flutter Linux app on ARM64 using emulation
|
|
# Build with: docker buildx build --platform linux/arm64 -t pdf_signature_arm64 .
|
|
|
|
FROM --platform=linux/arm64 ghcr.io/cirruslabs/flutter:latest AS build
|
|
|
|
# Install dependencies for Linux build (if not already in the image)
|
|
RUN apt-get update && apt-get install -y \
|
|
clang \
|
|
cmake \
|
|
ninja-build \
|
|
pkg-config \
|
|
libgtk-3-dev \
|
|
libblkid-dev \
|
|
liblzma-dev \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Enable Linux desktop support
|
|
RUN flutter config --enable-linux-desktop
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Copy pubspec files first for better caching
|
|
COPY pubspec.* ./
|
|
|
|
# Get dependencies
|
|
RUN flutter pub get
|
|
|
|
# Copy the rest of the project
|
|
COPY . .
|
|
|
|
# Enable Linux desktop platform for the project
|
|
RUN flutter create . --platforms linux
|
|
|
|
# Generate localization and build runner
|
|
RUN flutter gen-l10n
|
|
RUN flutter pub run build_runner build --delete-conflicting-outputs
|
|
|
|
# Build the Linux app for ARM64 (explicitly specify, though container is ARM64)
|
|
RUN flutter build linux --target-platform linux-arm64 --release
|
|
|
|
# Final stage: Create a minimal runtime image
|
|
FROM --platform=linux/arm64 ubuntu:22.04 AS runtime
|
|
|
|
# Install runtime dependencies
|
|
RUN apt-get update && apt-get install -y \
|
|
libgtk-3-0 \
|
|
libblkid1 \
|
|
liblzma5 \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copy the built app
|
|
COPY --from=build /app/build/linux/arm64/release/bundle /app
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Run the app with bundled libraries
|
|
CMD ["sh", "-c", "LD_LIBRARY_PATH=/app/lib:$LD_LIBRARY_PATH ./pdf_signature"] |