Dockerfile
928 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
FROM node:current-alpine as build-stage
ARG command
ENV COMMAND=${command}
# npm镜像,解决报错而引入
RUN npm config set registry https://registry.npmmirror.com
# install simple http server for serving static content
# 全局http-server用于本地运行
#RUN npm install -g http-server
# make the 'app' folder the current working directory
WORKDIR /app
# copy both 'package.json' and 'package-lock.json' (if available)
COPY web/package*.json ./
# install project dependencies
RUN npm install
# copy project files and folders to the current working directory (i.e. 'app' folder)
COPY web/ .
# build app for production with minification
RUN npm run ${COMMAND}
# production stage
#代理nginx,nginx直接访问
FROM caddy:alpine as production-stage
COPY --from=build-stage /app/dist /srv
EXPOSE 80
CMD ["caddy", "file-server", "--root", "/srv"]
#本地对应端口
#EXPOSE 8088
#CMD [ "http-server", "dist" ]