-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
74 lines (54 loc) · 1.9 KB
/
Dockerfile
File metadata and controls
74 lines (54 loc) · 1.9 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
61
62
63
64
65
66
67
68
69
70
71
72
73
# 使用带有 Node.js 和 git 的轻量级基础镜像
FROM node:20-alpine
# 设置 Aliyun 镜像源为3.13版本用以下载Python3.8并更新包列表
RUN echo "https://mirrors.aliyun.com/alpine/v3.13/main" > /etc/apk/repositories && \
echo "https://mirrors.aliyun.com/alpine/v3.13/community" >> /etc/apk/repositories && \
apk update
# && apk --no-cache add ttf-dejavu fontconfig
# 设置维护者信息
LABEL maintainer="Golu goluli@qq.com"
# 安装 git
RUN apk add --no-cache git
# 更新包列表并安装必要的软件包
RUN apk add --no-cache openssl
# ########## 安装Python3.8 ##################
# 安装必要的构建工具和 Python 3
RUN apk add --no-cache \
python3 \
python3-dev
# 创建符号链接以确保 python 命令指向 python3
RUN ln -sf /usr/bin/python3 /usr/bin/python
# 设置 Aliyun 镜像源版本为3.19并更新包列表
RUN echo "https://mirrors.aliyun.com/alpine/v3.19/main" > /etc/apk/repositories && \
echo "https://mirrors.aliyun.com/alpine/v3.19/community" >> /etc/apk/repositories && \
apk update
RUN apk add --no-cache \
make \
g++ \
bash
# 确认安装的 Python 版本和构建工具
RUN python --version && make --version && g++ --version
# ###############################################################
# 设置工作目录
WORKDIR /app
# 克隆前端项目
RUN git clone https://gitee.com/golu-ljg/golu-navigation-web.git /tmp/app
# 进入临时目录,安装依赖并构建项目
WORKDIR /tmp/app
RUN npm install
RUN npm run build
# 将构建后的文件移动到/app目录下
RUN mv dist /app/
# 返回/app目录,清理临时文件
WORKDIR /app
RUN rm -rf /tmp/app
# 复制文件到运行目录
COPY . .
# 创建数据库目录并设置权限
RUN mkdir -p /app/database && chmod -R 755 /app/database
# 安装依赖
RUN npm install
# 暴露应用需要的端口
EXPOSE 8082
# 指定容器启动命令
CMD ["node", "/app/app.js"]