FROM node:20-bookworm

RUN apt-get update
RUN apt-get install -y apt-transport-https git ca-certificates curl gnupg python3 python3-pip make build-essential mariadb-client wget zip unzip xz-utils

WORKDIR /root

RUN curl -fsSL https://bun.sh/install | bash
ENV PATH="/root/.bun/bin:${PATH}"

# Install Global Modules
COPY .npmrc /root/.bun/install/global/.npmrc
RUN bun add -g @moduletrace/buncid

COPY docker/mariadb/.mariadb_history /root/.mariadb_history
COPY docker/mariadb/.bash_history /root/.bash_history
COPY docker-entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh

HEALTHCHECK --interval=10s --timeout=5s --retries=10 CMD curl -f http://localhost:$DSQL_PORT/ || exit 1

ENTRYPOINT ["entrypoint.sh"]
