-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
64 lines (41 loc) · 1.18 KB
/
Dockerfile
File metadata and controls
64 lines (41 loc) · 1.18 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# 使用 node 镜像
FROM node:18.12.0-alpine AS build-stage-node
# Set the maximum memory limit for the Node.js process
ENV NODE_OPTIONS="--max-old-space-size=10240"
# 构建参数
ARG BUILD_ENV
## 安装 一些基础包
RUN apk update \
&& apk upgrade \
&& apk add git \
&& apk add bash
# ## 设置 操作系统时区
RUN rm -rf /etc/localtime \
&& ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
# 设置容器内的目录,通常我们会使用 app 目录
WORKDIR /app
# 项目文件拷贝到容器 /app 下
COPY ./package.json .
COPY ./pnpm-lock.yaml .
COPY ./.npmrc .
RUN npm config set registry https://registry.npmmirror.com
RUN npm install -g pnpm@9.1.1
# 下载依赖包,并构建打包文件
RUN pnpm i --frozen-lockfile
COPY . .
RUN pnpm run build
# 使用 nginx 镜像
FROM nginx:latest
# 设置编码
ENV LANG C.UTF-8
# 同步时间
ENV TZ=Asia/Shanghai
# 将我们在 node 镜像的打包文件拷贝到这里
COPY --from=build-stage-node /app/dist /data/h5/
# 配置 nginx
ADD default.conf /etc/nginx/conf.d/
RUN mkdir -p /data/h5/ /data/logs/ && chmod -R a+x /data/h5/
# 暴露端口
EXPOSE 80
# 启动 nginx
CMD ["/usr/sbin/nginx", "-g", "daemon off;"]