Bootstrap: docker
From: mcr.microsoft.com/dotnet/sdk:9.0
Stage: build

%files
  . /build

# Install apt packages
%post
  apt update \
    && apt install -y p7zip-full git procps ssh-client

  apt autoremove -y \
    && apt clean -y \
    && rm -rf /var/lib/apt/lists/*

# Build application
%post
  cd /build/src/Archivist
  dotnet restore --force-evaluate
  dotnet run bundle


Bootstrap: docker
From: mcr.microsoft.com/dotnet/runtime:9.0
Stage: runtime

%files from build
  /build/src/Archivist/dist /app

%post
  apt update \
    && apt install -y libnetcdf-dev

  apt autoremove -y \
    && apt clean -y \
    && rm -rf /var/lib/apt/lists/*

  dotnet_version=`ls /usr/share/dotnet/shared/Microsoft.NETCore.App`
  ln -s /usr/lib/x86_64-linux-gnu/libdl.so.2 /usr/share/dotnet/shared/Microsoft.NETCore.App/${dotnet_version}/libdl.so

%environment
  export ARCHMAESTER_URL="https://maps.oceanbox.io"
  export ARCHMAESTER_AUTH="admin:en-to-tre-fire"

%runscript
  exec /app/archivist "$@"