29 lines
666 B
Docker
29 lines
666 B
Docker
# 1. Construction du site (Vite)
|
|
FROM node:lts AS build
|
|
|
|
WORKDIR /app
|
|
|
|
COPY package*.json ./
|
|
|
|
RUN npm install
|
|
|
|
COPY . .
|
|
|
|
RUN npm run build
|
|
|
|
# 2. Image finale : uniquement le dist/ construit et le serveur statique
|
|
FROM node:lts-alpine
|
|
|
|
WORKDIR /app
|
|
|
|
RUN npm install -g http-server
|
|
|
|
COPY --from=build /app/dist ./dist
|
|
|
|
EXPOSE 4001
|
|
|
|
# -c-1 : pas de cache navigateur longue durée, sinon après un déploiement index.html (mis en cache 1 h)
|
|
# peut référencer des assets hachés qui n'existent plus
|
|
# -P : toute route inconnue renvoie index.html (routeur Vue en mode history)
|
|
CMD ["http-server", "dist", "-p", "4001", "-c-1", "-P", "http://localhost:4001?/"]
|