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 --lts --latest-npm

# Add node and npm to path so the commands are available
ENV NODE_PATH=$NVM_DIR/versions/v$NODE_VERSION/lib/node_modules
ENV PATH=$NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH

# Install semantic release and conventional commits cli
RUN 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

RUN mkdir -p /workspace
WORKDIR /workspace
USER root
