# Use Node.js as the base image
FROM node:22.17.1-bookworm-slim

# Set the working directory inside the container
WORKDIR /usr/src/app

# Copy package.json and package-lock.json
COPY front/package*.json ./

# Install dependencies
RUN npm install

# Copy the rest of the application
COPY front/ .

# Importar las variables en build-time
ARG VITE_API_URL
ARG VITE_ALLOWED_HOSTS
ENV VITE_API_URL=${VITE_API_URL}
ENV VITE_ALLOWED_HOSTS=${VITE_ALLOWED_HOSTS}

# Build the Svelte application
RUN npm run build

# Expose the port the app runs on
EXPOSE 80 5173

# Copiar y usar el entrypoint que arranca sshd + uvicorn
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

CMD ["/entrypoint.sh"]