content: # ╔═════════════════════════════════════════════════════╗
  # ║                       SETUP                         ║
  # ╚═════════════════════════════════════════════════════╝
  # GLOBAL
    ARG APP_UID=1000 \
        APP_GID=1000 \
        BUILD_SRC=https://github.com/animetosho/par2cmdline-turbo \
        BUILD_ROOT=/par2cmdline-turbo
    ARG BUILD_BIN=${BUILD_ROOT}/par2
  
  # :: FOREIGN IMAGES
    FROM 11notes/util:bin AS util-bin
  
  
  # ╔═════════════════════════════════════════════════════╗
  # ║                       BUILD                         ║
  # ╚═════════════════════════════════════════════════════╝
  # :: PAR2
    FROM alpine AS build
    COPY --from=util-bin / /
    ARG APP_VERSION \
        APP_ROOT \
        BUILD_SRC \
        BUILD_ROOT \
        BUILD_BIN
  
    RUN set -ex; \
      apk --no-cache --update add \
        autoconf \
        automake \
        build-base \
        libffi-dev \
        openssl-dev \
        python3-dev \
        git;
  
    RUN set -ex; \
      git clone ${BUILD_SRC} -b v${APP_VERSION};
  
    RUN set -ex; \
      cd ${BUILD_ROOT}; \
      ./automake.sh; \
      ./configure \
        --prefix="/usr"; \
      make -s -j $(nproc) V=1 LDFLAGS="--static" 2>&1 > /dev/null;
  
    RUN set -ex; \
      eleven distroless ${BUILD_BIN};
  
  
  # ╔═════════════════════════════════════════════════════╗
  # ║                       IMAGE                         ║
  # ╚═════════════════════════════════════════════════════╝
  # :: HEADER
    FROM scratch
  
    # :: default arguments
      ARG TARGETPLATFORM \
          TARGETOS \
          TARGETARCH \
          TARGETVARIANT \
          APP_IMAGE \
          APP_NAME \
          APP_VERSION \
          APP_ROOT \
          APP_UID \
          APP_GID \
          APP_NO_CACHE
  
    # :: default environment
      ENV APP_IMAGE=${APP_IMAGE} \
          APP_NAME=${APP_NAME} \
          APP_VERSION=${APP_VERSION} \
          APP_ROOT=${APP_ROOT}
  
    # :: multi-stage
      COPY --from=build ${APP_ROOT}/ /
  
  # :: EXECUTE
    USER ${APP_UID}:${APP_GID}
    ENTRYPOINT ["/usr/local/bin/par2"]
    CMD ["--version"]