FROM docker.io/rust:1.84.0-alpine3.21

LABEL org.opencontainers.image.source=https://git.ragarock.moe/silvana/rust

RUN apk add --no-cache curl=8.11.1-r0
RUN curl -L https://github.com/cargo-bins/cargo-binstall/releases/download/v1.10.19/cargo-binstall-x86_64-unknown-linux-musl.tgz -o cargo-binstall.tgz && \
  tar -xzf cargo-binstall.tgz && \
  rm cargo-binstall.tgz && \
  mv cargo-binstall /usr/local/bin/

RUN cargo binstall -y \
  cargo-chef@0.1 \
  cargo-hack@0.6 \
  cargo-machete@0.7 \
  cargo-mutants@25.0 \
  release-plz@0.3

# should be a no-op if the FROM line is up-to-date
RUN rustup update stable 

RUN rustup component add --toolchain stable-x86_64-unknown-linux-musl rustfmt clippy

# install nightly
RUN rustup install nightly && rustup component add --toolchain nightly rustfmt clippy

# nodejs - runtime used by forgejo/github actions
# curl - to download cargo-binstall
# clang & mold - faster linkers for rust
# pkgconfig - required to compile some rust `-sys` packages
# openssl-dev - build dependency for git-next
# dbus-dev - linux os interop (e.g. desktop notifications)
# perl - native-tls(vendored)
# git - git
RUN apk add --no-cache \
  bash \
  nodejs \
  build-base \
  pkgconfig \
  libssl3 \
  openssl-dev \
  perl \
  dbus-dev \
  git

  # clang \

  # mold \

  # dbus-dev \

RUN git config --global user.email "holo@ragarock.moe" && \
  git config --global user.name "ForgeJo Action. See: https://git.ragarock.moe/silvana/rust"

COPY scripts/ /usr/local/bin/

WORKDIR /app