fix(Dockerfile, Makefile, manifest): Address user/group ID mapping and attempt to resolve ninja errors

This commit is contained in:
2025-05-07 03:04:41 +08:00
parent 78c3eed0fc
commit 1b4744024b
3 changed files with 84 additions and 59 deletions

View File

@@ -4,7 +4,11 @@ FROM debian:12-slim
# Set environment variables for non-interactive install
ENV DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC
# Install necessary tools: Flatpak, builder, git, etc.
# Arguments for user and group ID
ARG UID=1000
ARG GID=1000
# Install necessary tools: Flatpak, builder, git, ccache, etc.
RUN apt-get update && \
apt-get install -y --no-install-recommends \
flatpak \
@@ -14,6 +18,7 @@ RUN apt-get update && \
unzip \
ca-certificates \
elfutils \
ccache \
# Build dependencies for system libraries
build-essential \
ninja-build \
@@ -28,15 +33,28 @@ RUN flatpak remote-add --system --if-not-exists flathub https://flathub.org/repo
flatpak install --system --noninteractive flathub org.freedesktop.Sdk//23.08 && \
flatpak install --system --noninteractive flathub org.freedesktop.Platform//23.08
# Create a non-root user for the build process
RUN groupadd -g $GID builder && \
useradd -u $UID -g $GID -ms /bin/bash builder && \
mkdir -p /home/builder/.cache/ccache && \
chown -R builder:builder /home/builder
# Create directories needed for the build and set ownership
# /sources will be mounted from host, /build is for build artifacts
RUN mkdir -p /sources /build && \
chown -R builder:builder /build
# Set user and home directory
USER builder
ENV HOME /home/builder
ENV CCACHE_DIR /home/builder/.cache/ccache
ENV PATH /usr/lib/ccache:$PATH
# Set working directory for the build process
WORKDIR /build
# Create cache-friendly directory structure
# This creates a clear layer separation for better Docker/Flatpak caching
RUN mkdir -p /sources /build/cache /build/build-dir /build/repo
# Copy the Flatpak manifest into the build directory
COPY com.aseprite.Aseprite.yaml .
# Copy the Flatpak manifest into the build directory (owned by builder due to WORKDIR and USER settings)
COPY --chown=builder:builder com.aseprite.Aseprite.yaml .
# Default command for interactive use
CMD ["bash"]