feat: add multi-arch Dockerfile for ARM64 support
This commit is contained in:
parent
e806c3c830
commit
3bc1395a7c
|
|
@ -2,6 +2,8 @@
|
|||
.dockerignore
|
||||
.git
|
||||
.gitignore
|
||||
.env
|
||||
.secrets
|
||||
.idea
|
||||
.vscode
|
||||
**/.DS_Store
|
||||
|
|
|
|||
|
|
@ -139,3 +139,4 @@ appimage-build/
|
|||
*.patch
|
||||
*.freezed.dart
|
||||
*.g.dart
|
||||
/output/
|
||||
29
.metadata
29
.metadata
|
|
@ -4,7 +4,7 @@
|
|||
# This file should be version controlled and should not be manually edited.
|
||||
|
||||
version:
|
||||
revision: "35c388afb57ef061d06a39b537336c87e0e3d1b1"
|
||||
revision: "ac4e799d237041cf905519190471f657b657155a"
|
||||
channel: "stable"
|
||||
|
||||
project_type: app
|
||||
|
|
@ -13,26 +13,23 @@ project_type: app
|
|||
migration:
|
||||
platforms:
|
||||
- platform: root
|
||||
create_revision: 35c388afb57ef061d06a39b537336c87e0e3d1b1
|
||||
base_revision: 35c388afb57ef061d06a39b537336c87e0e3d1b1
|
||||
create_revision: ac4e799d237041cf905519190471f657b657155a
|
||||
base_revision: ac4e799d237041cf905519190471f657b657155a
|
||||
- platform: android
|
||||
create_revision: 35c388afb57ef061d06a39b537336c87e0e3d1b1
|
||||
base_revision: 35c388afb57ef061d06a39b537336c87e0e3d1b1
|
||||
create_revision: ac4e799d237041cf905519190471f657b657155a
|
||||
base_revision: ac4e799d237041cf905519190471f657b657155a
|
||||
- platform: ios
|
||||
create_revision: 35c388afb57ef061d06a39b537336c87e0e3d1b1
|
||||
base_revision: 35c388afb57ef061d06a39b537336c87e0e3d1b1
|
||||
create_revision: ac4e799d237041cf905519190471f657b657155a
|
||||
base_revision: ac4e799d237041cf905519190471f657b657155a
|
||||
- platform: linux
|
||||
create_revision: 35c388afb57ef061d06a39b537336c87e0e3d1b1
|
||||
base_revision: 35c388afb57ef061d06a39b537336c87e0e3d1b1
|
||||
create_revision: ac4e799d237041cf905519190471f657b657155a
|
||||
base_revision: ac4e799d237041cf905519190471f657b657155a
|
||||
- platform: macos
|
||||
create_revision: 35c388afb57ef061d06a39b537336c87e0e3d1b1
|
||||
base_revision: 35c388afb57ef061d06a39b537336c87e0e3d1b1
|
||||
- platform: web
|
||||
create_revision: 35c388afb57ef061d06a39b537336c87e0e3d1b1
|
||||
base_revision: 35c388afb57ef061d06a39b537336c87e0e3d1b1
|
||||
create_revision: ac4e799d237041cf905519190471f657b657155a
|
||||
base_revision: ac4e799d237041cf905519190471f657b657155a
|
||||
- platform: windows
|
||||
create_revision: 35c388afb57ef061d06a39b537336c87e0e3d1b1
|
||||
base_revision: 35c388afb57ef061d06a39b537336c87e0e3d1b1
|
||||
create_revision: ac4e799d237041cf905519190471f657b657155a
|
||||
base_revision: ac4e799d237041cf905519190471f657b657155a
|
||||
|
||||
# User provided section
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,62 @@
|
|||
# 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"]
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
|
||||
one time
|
||||
[Manage Docker as a non-root user](https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user)
|
||||
|
||||
```bash
|
||||
docker run --privileged --rm tonistiigi/binfmt --install all
|
||||
docker buildx create --use --name multiarch
|
||||
```
|
||||
|
||||
build
|
||||
|
||||
```bash
|
||||
docker buildx build --platform linux/arm64 -f Dockerfile.arm64 -t pdf_signature_arm64 .
|
||||
```
|
||||
|
||||
Extract the Built App
|
||||
|
||||
```bash
|
||||
mkdir output
|
||||
docker run --rm -v $(pwd)/output:/output pdf_signature_arm64 cp -r /app /output
|
||||
mkdir output/lib
|
||||
# docker run --rm -v $(pwd)/output:/output pdf_signature_arm64 ldd /app/pdf_signature
|
||||
docker run --rm -v $(pwd)/output:/output pdf_signature_arm64 sh -c "ldd /app/pdf_signature | grep '=>' | awk '{print \$3}' | grep -v libc | xargs -I {} cp -L {} /output/lib"
|
||||
# docker run --rm -v $(pwd)/output:/output pdf_signature_arm64 ls /app/lib
|
||||
# tree output/
|
||||
```
|
||||
|
|
@ -21,6 +21,14 @@ version: 1.1.0+1
|
|||
environment:
|
||||
sdk: ^3.7.0
|
||||
|
||||
platforms:
|
||||
android:
|
||||
ios:
|
||||
linux:
|
||||
macos:
|
||||
web:
|
||||
windows:
|
||||
|
||||
# Dependencies specify other packages that your package needs in order to work.
|
||||
# To automatically upgrade your package dependencies to the latest versions
|
||||
# consider running `flutter pub upgrade --major-versions`. Alternatively,
|
||||
|
|
|
|||
Loading…
Reference in New Issue