FROM debian:bookworm

LABEL version="0.0.1"
LABEL description="Packed with essential tools for Freeleaps DevOps System"
LABEL maintainer="Freeleaps <https://freeleaps.com>"

ARG DEBIAN_FRONTEND=noninteractive

SHELL ["/bin/bash", "-l", "-euxo", "pipefail", "-c"]

USER root

# Install essential tools
RUN apt-get update; \
    apt-get full-upgrade -y; \
    apt-get install -y --no-install-recommends \
    git \
    curl \
    wget \
    unzip \
    vim \
    nano \
    jq \
    dnsutils \
    net-tools \
    iputils-ping \
    iproute2 \
    telnet \
    openssh-client \
    bash \
    ca-certificates \
    ; \
    apt-get clean; \
    rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

ENV NVM_DIR=/usr/local/nvm

# Install nvm to management node versions
RUN mkdir -p "$NVM_DIR"; \
    curl -o- \
      "https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh" | \
      bash \
    ; \
    source $NVM_DIR/nvm.sh; \
    nvm install v22.14.0 --latest-npm; \
    ln -s $NVM_DIR/versions/node/v22.14.0/bin/node /usr/local/bin/node; \
    ln -s $NVM_DIR/versions/node/v22.14.0/bin/npm /usr/local/bin/npm; \
    ln -s $NVM_DIR/versions/node/v22.14.0/bin/npx /usr/local/bin/npx


# Install semantic release and conventional commits cli
RUN npm config set prefix /usr/local; \
  npm install -g \
  semantic-release \
  @semantic-release/changelog \
  @semantic-release/git \
  @semantic-release/exec \
  @semantic-release/release-notes-generator \
  conventional-changelog-conventionalcommits \
  @commitlint/cli \
  @commitlint/config-conventional \
  @commitlint/config-angular

USER root
