1👍
✅
You haven’t copied any files between the develop-stage
and build-stage
so there’s no node_modules
and thus, no vite
.
I recommend you create two separate Dockerfiles for development and production.
For example
Development
# Dockerfile.dev
FROM node:lts-alpine as build-stage
WORKDIR /app
COPY package*.json ./
RUN yarn
CMD yarn dev
# compose.yaml
services:
vue-app:
build:
context: .
dockerfile: Dockerfile.dev
ports:
- "8080:8080"
volumes:
- .:/app
- /app/node_modules
Production
# Dockerfile
# build stage
FROM node:lts-alpine as build-stage
ENV NODE_ENV=production
WORKDIR /app
COPY package*.json ./
RUN yarn
COPY . .
RUN yarn build
# production stage
FROM nginx:stable-alpine as production-stage
COPY --from=build-stage /app/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
👤Phil
Source:stackexchange.com