# Use Node.js LTS image as base
FROM node:lts

# Set working directory
WORKDIR /app

# Copy repository into container
COPY . .

# Install Node Version Manager
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash

# Install Node.js v18.14.0
RUN /bin/bash -c "source ~/.bashrc && nvm install v18.14.0"

# Export path to installed Node.js
RUN echo 'export PATH="/home/astra/.nvm/versions/node/v18.14.0/bin:${PATH}"' >> ~/.bashrc

# Activate NVM
SHELL ["/bin/bash", "--login", "-c"]

# Configure npm registry
RUN npm config --global set 'registry=https://nexuswatchman.t1-consulting.ru/repository/npm-group/'
RUN npm config --global set 'fund=false'

# Install npm dependencies
RUN npm install

# Create environment file
RUN touch .env.local

# Populate environment file with backend URL
RUN echo 'API_URL="http://172.31.142.195:8080"' >> .env.local

# Expose port 3000
EXPOSE 3000

# Command to run the development server
CMD ["npm", "run", "dev"]


