FROM node:22.1-bullseye

# Install git and other dependencies
RUN apt-get update && apt-get install -y bash build-essential git zsh \
    && rm -rf /var/lib/apt/lists/* 


# Install Oh My Zsh
RUN bash -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" && \
    sed -i 's/ZSH_THEME="robbyrussell"/ZSH_THEME="agnoster"/' /root/.zshrc

# Optional: Set zsh as the default shell for the root user
RUN chsh -s $(which zsh)

# Clone your Next.js application
ARG GIT_USERNAME
ARG GIT_PASSWORD
RUN git clone https://${GIT_USERNAME}:${GIT_PASSWORD}@git.workouttest.org/bossanyit/voxadata_app /app/voxadata_app

# Clone the second repository
RUN git clone https://${GIT_USERNAME}:${GIT_PASSWORD}@git.workouttest.org/bossanyit/voxadata_bot /app/voxadata_bot


RUN npm install -g corepack

# Install and use yarn 4.x
RUN corepack enable && corepack prepare yarn@4.1.0 --activate

# Set the working directory to /app/voxadata_app
WORKDIR /app/voxadata_app
RUN ls -la
# Check Yarn configuration and install dependencies
RUN yarn config set cacheFolder .yarn/cache && yarn install


# Set the working directory to /app/voxadata_bot
WORKDIR /app/voxadata_bot
RUN ls -la
# Check Yarn configuration and install dependencies
RUN yarn config set cacheFolder .yarn/cache && yarn install


# Expose ports
EXPOSE 3000
EXPOSE 3001

# Run the app when the container launches
CMD ["tail", "-f", "/dev/null"]
