All checks were successful
Workflow de prueba / Build and push images (push) Successful in 1m27s
39 lines
693 B
Docker
39 lines
693 B
Docker
# frontend/Dockerfile
|
|
|
|
# 1) Fase de build
|
|
FROM node:20-alpine AS build
|
|
|
|
WORKDIR /app
|
|
|
|
# Copiamos sólo package.json para cachear mejor
|
|
COPY package*.json ./
|
|
|
|
RUN npm install
|
|
|
|
# Copiamos el resto del código
|
|
COPY . .
|
|
|
|
# Variable para que el front apunte a nginx (/api -> backend)
|
|
ARG VITE_API_BASE_URL=/api
|
|
ENV VITE_API_BASE_URL=${VITE_API_BASE_URL}
|
|
|
|
# Construimos el bundle
|
|
RUN npm run build
|
|
|
|
# 2) Fase de servidor estático
|
|
# FROM node:20-alpine
|
|
FROM nginx:alpine
|
|
|
|
# WORKDIR /app
|
|
RUN rm -rf /usr/share/nginx/html/*
|
|
|
|
# Copiamos el build
|
|
COPY --from=build /app/dist /usr/share/nginx/html
|
|
|
|
# Server estático muy simple
|
|
# RUN npm install -g serve
|
|
|
|
EXPOSE 80
|
|
|
|
CMD ["nginx", "-g", "daemon off;"]
|