# 使用基础镜像
FROM node:18.12.0-slim
# 备份镜像源
RUN cp /etc/apt/sources.list /etc/apt/sources.list_bak
# 镜像源修改为国内
RUN sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
# 安装chromium 运行环境需要的依赖
RUN apt update -y && apt install -y libnss3-dev libatk1.0-dev libatk-bridge2.0-dev \
libcups2-dev libdrm-dev libxkbcommon-dev libxcomposite-dev libxdamage-dev \
libxrandr-dev libgbm-dev libasound-dev yarn libpangocairo-1.0-0
RUN apt install -y gconf-service libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxss1 libxtst6 libappindicator1 libnss3 libasound2 libatk1.0-0 libc6 ca-certificates fonts-liberation lsb-release xdg-utils wget
# 设置环境变量
ENV APP_PATH /app
#设置工作区
WORKDIR ${APP_PATH}
# 使用用户
USER root
# copy代码到镜像内
COPY . ${APP_PATH}
# 安装全局pm2
RUN yarn global add pm2
# 安装项目依赖
RUN yarn
# 默认安装的是chrom ,若要使用firefox则单独调用安装
RUN npx puppeteer browsers install firefox
# 启动项目
CMD npm run start
docker 镜像构建
docker build -t dockerimgaes:版本 项目根目录
docker build -t test:v1 .
docker 创建容器
docker run -d --name 容器名 -v /opt/log:/app/log --cap-add SYS_TIME 镜像名:版本号
docker 容器中文字体支持不友好。进入进行修改
docker exec -it 容器名 /bin/bash
更新字体
1. 使用以下命令更新系统软件包列表:
apt update
2. 安装中文字体支持包:
apt install fonts-noto-cjk
这将安装Noto字体系列,其中包含了广泛的中文字体。
3. 安装中文字体配置包:
apt install fontconfig
4. 配置中文字体:
dpkg-reconfigure fontconfig-config
在配置过程中,选择"自动"选项以使用系统默认设置。
5. 更新字体缓存:
fc-cache -f -v
这将更新系统中的字体缓存。
完成以上步骤后,系统将安装了中文字体,并且可以在应用程序中正常显示中文内容。