forked from aki/docker-aseprite-linux
This commit introduces a major refactoring of the Aseprite build process. It replaces the previous fragile system (prone to dependency fetching failures) with an interim multi-distribution Docker approach, paving the way for a future transition to Flatpak.
**Problems Addressed:**
* **Build Fragility & Dependency Fetching:** The prior method, compiling dependencies from source within a generic container, frequently failed due to network issues and rate limiting during source/sub-dependency acquisition (e.g., Skia's `git-sync-deps`), often late in the process. Source state inconsistencies could also cause failures.
* **Complexity of Full Source Builds:** Managing the compilation of the entire dependency tree from source was complex.
**New Architecture & Rationale:**
* **Host-Side Source Preparation (`prepare_sources.sh`):** Isolates the problematic source fetching and state management to a host-side script run *before* the main build. Key features:
* Handles cloning/updating core sources (`depot_tools`, Skia, Aseprite).
* Runs Skia `git-sync-deps` with **robust retry logic** to specifically address rate limit errors.
* Includes an `--check-integrity` flag which performs **aggressive checks and resets** (fetching, checking out specific tags/commits, resetting state) to ensure the local source directories precisely match the required state for the build, potentially involving significant network activity.
* **Distribution-Specific Builds (Interim Step):** Introduced `Dockerfile.arch`, `Dockerfile.debian`, `Dockerfile.fedora`. These use native package managers to install pre-built *common* development libraries within the container, simplifying the Docker build stage itself. Requires OS detection or manual selection (`TARGET_DISTRO`).
* **Clear Build Stages (Makefile):** Orchestrates source preparation, image building, and final binary extraction (`docker cp` to `./output/bin`).
* **Cleaned Structure:** Removed obsolete scripts/files (`compile.sh`, generic `Dockerfile`, `docker-compose.yml`) and updated `.gitignore`.
**Limitations & Future Direction (Flatpak):**
* **Fetching Challenges Persist:** While reliability is improved by isolating source prep and adding retries/integrity checks in `prepare_sources.sh`, the core challenge of potential rate limits or network issues during this initial step remains.
* **Flatpak for Portability:** The current multi-distro Docker setup is an **intermediate solution**. The ultimate goal and **forward-maintained approach** is migrating to **Flatpak (`flatpak-builder`)**. Flatpak will provide a **unified, distribution-agnostic build environment** using standard runtimes and produce a **portable `.flatpak` bundle**, eliminating the need for OS detection/separate Dockerfiles and ensuring consistent builds *after* sources are successfully prepared.
99 lines
3.2 KiB
Docker
99 lines
3.2 KiB
Docker
# Use Debian 12 (Bookworm) slim as the base image
|
|
FROM debian:12-slim
|
|
|
|
# Set frontend to noninteractive to avoid prompts during package installation
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
ENV TZ=Etc/UTC
|
|
|
|
# Install necessary dependencies using apt-get
|
|
# Includes build tools, git, python, cmake, ninja, curl, unzip, ca-certs,
|
|
# and development libraries for X11, GL, fontconfig, and Skia dependencies.
|
|
RUN apt-get update && \
|
|
apt-get install -y --no-install-recommends \
|
|
build-essential \
|
|
git \
|
|
python3 \
|
|
cmake \
|
|
ninja-build \
|
|
curl \
|
|
unzip \
|
|
ca-certificates \
|
|
libx11-dev \
|
|
libxcursor-dev \
|
|
libxi-dev \
|
|
libgl1-mesa-dev \
|
|
libfontconfig1-dev \
|
|
libexpat1-dev \
|
|
libicu-dev \
|
|
libjpeg-turbo8-dev \
|
|
libpng-dev \
|
|
libwebp-dev \
|
|
zlib1g-dev \
|
|
libfreetype6-dev \
|
|
libharfbuzz-dev \
|
|
# Clean up apt lists to reduce image size
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Set the working directory
|
|
WORKDIR /app
|
|
|
|
# Copy the pre-downloaded source code into the image
|
|
# This assumes prepare_sources.sh has been run locally first
|
|
COPY ./src /src
|
|
|
|
# Set PATH for depot_tools
|
|
ENV PATH="/src/depot_tools:${PATH}"
|
|
|
|
# Initialize depot_tools within the container environment
|
|
# This ensures gn and other tools are correctly set up
|
|
RUN update_depot_tools
|
|
|
|
# --- Compile Skia ---
|
|
WORKDIR /src/skia
|
|
|
|
# Skia dependencies (including gn) are now synced locally by prepare_sources.sh
|
|
# Skia system dependencies are handled by system packages installed via apt-get
|
|
|
|
# Generate Skia build files using Debian's system libraries
|
|
# Note: Changed skia_use_system_* flags to true and enabled AVX
|
|
RUN /src/depot_tools/gn gen out/Release-x64 --args='is_debug=false is_official_build=true skia_use_system_expat=true skia_use_system_icu=true skia_use_system_libjpeg_turbo=true skia_use_system_libpng=true skia_use_system_libwebp=true skia_use_system_zlib=true skia_use_sfntly=false skia_use_freetype=true skia_use_harfbuzz=true skia_pdf_subset_harfbuzz=true skia_use_system_freetype2=true skia_use_system_harfbuzz=true extra_cflags=["-mavx"] extra_cxxflags=["-mavx"]'
|
|
|
|
# Compile Skia
|
|
RUN ninja -C out/Release-x64 skia modules
|
|
|
|
# --- Compile Aseprite ---
|
|
WORKDIR /src/aseprite
|
|
RUN mkdir -p build
|
|
WORKDIR /src/aseprite/build
|
|
|
|
# Generate Aseprite build files
|
|
# Pointing to the Skia build output within the image and enabling AVX
|
|
RUN cmake \
|
|
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
|
|
-DCMAKE_CXX_FLAGS="-mavx" \
|
|
-DLAF_BACKEND=skia \
|
|
-DSKIA_DIR=/src/skia \
|
|
-DSKIA_LIBRARY_DIR=/src/skia/out/Release-x64 \
|
|
-DSKIA_LIBRARY=/src/skia/out/Release-x64/libskia.a \
|
|
-DLIBJPEG_TURBO_LIBRARY=/usr/lib/x86_64-linux-gnu/libjpeg.so \
|
|
-DCMAKE_EXE_LINKER_FLAGS="-lfreetype" \
|
|
-G Ninja \
|
|
..
|
|
|
|
# Compile Aseprite
|
|
RUN ninja aseprite
|
|
|
|
# --- Prepare Output ---
|
|
# Create a target directory and copy the final binaries/assets
|
|
RUN mkdir -p /target/aseprite/build/bin
|
|
RUN cp /src/aseprite/build/bin/aseprite /target/aseprite/build/bin/
|
|
# Ensure data directory exists before copying into it
|
|
RUN mkdir -p /target/aseprite/build/bin/data
|
|
RUN cp /src/aseprite/build/bin/data/* /target/aseprite/build/bin/data/
|
|
|
|
# Expose a volume for the output (optional, as Makefile will copy)
|
|
VOLUME /target
|
|
|
|
# Set final working directory (optional)
|
|
WORKDIR /target
|