# PREPARATION
	# Create temporary package.json where version is set to "0.0.0"
	# This way the cache of the build step won't be invalidated if only the version changed.
	FROM node:lts-alpine AS preparation
	COPY package.json service/create-tmp-pkg.js ./
	RUN node create-tmp-pkg.js

# BUILD
	# Usa la imagen oficial de Node.js como base
	FROM node:22-alpine AS build

	# Establece el directorio de trabajo dentro del contenedor
	WORKDIR /usr/src/app

	# Copia e instala las dependencias
	COPY --from=preparation package*.json ./
	RUN yarn install

	# Copia el resto del código fuente
	COPY . .

	# Compila el código TypeScript a JavaScript
	# RUN npm run build

	# Expone el puerto que la aplicación usa
	EXPOSE 3000

	# Define el comando para ejecutar la aplicación
	CMD ["node", "dist/server.js"]
