将phantomjs制成docker镜像

几个前的一篇文章中介绍了phantomjs+echarts生成图表图片的一种方式,但其部署复杂,制作为docker镜像运行就方便多了。文章参见:https://blog.csdn.net/u011943534/article/details/121524397

1、准备echarts

将上次文章中提到过下载的EchartsConvert 解压,并复制到一个安装docker的服务器。

下载地址:https://gitee.com/saintlee/echartsconvert

2、准备phantomjs

将上次文章中个体到过下载的phantomjs解压,并复制bin目录下的phantomjs文件到上一步和echarts相同的目录

下载地址:https://bitbucket.org/ariya/phantomjs/downloads/

注意下载linux版本的

3、编写dockerfile

bash 复制代码
FROM debian:stable-slim
RUN apt-get update
RUN apt-get install -y apt-transport-https ca-certificates
 
#mirror
COPY sources.list /etc/apt/sources.list
 
#phantomjs
RUN apt-get update
RUN apt-get install -y libfontconfig1
ENV OPENSSL_CONF /etc/ssl/
COPY phantomjs /usr/local/bin
RUN chmod +x /usr/local/bin/phantomjs
ADD echartsconvert-master /echartsconvert-master
RUN apt-get install -y ttf-wqy-zenhei
RUN apt-get install -y xfonts-intl-chinese wqy*
RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

EXPOSE 7777
CMD ["/usr/local/bin/phantomjs", "/echartsconvert-master/echarts-convert.js", "-s", "-p", "7777"]

其中sources.list如下:

复制代码
deb https://mirrors.tencent.com/debian/ bullseye main non-free contrib
deb-src https://mirrors.tencent.com/debian/ bullseye main non-free contrib
deb https://mirrors.tencent.com/debian-security/ bullseye-security main
deb-src https://mirrors.tencent.com/debian-security/ bullseye-security main
deb https://mirrors.tencent.com/debian/ bullseye-updates main non-free contrib
deb-src https://mirrors.tencent.com/debian/ bullseye-updates main non-free contrib
deb https://mirrors.tencent.com/debian/ bullseye-backports main non-free contrib
deb-src https://mirrors.tencent.com/debian/ bullseye-backports main non-free contrib

4、构建镜像

bash 复制代码
docker build -t phantomjs:0.0.1 .

5、运行镜像

bash 复制代码
docker run -d --name=phantomjs --restart=always -p 7777:7777 phantomjs:0.0.1
相关推荐
生活爱好者!6 小时前
哇!影视新玩法!docker部署NEOWATCH NAS
运维·docker·容器
cpolar技术支持9 小时前
Docker 容器启动失败怎么查?端口、日志、权限与网络排障完整教程
linux·docker·容器·cpolar·网络排障
一技安身11 小时前
【大模型】Win11 部署 DeepSeek+ RAGFlow0.27.2 (Ollama方案,断网可用)
docker·ai·语言模型
新时代牛马12 小时前
docker run 起不来?从dockerd、containerd 到runc 一条线讲透
运维·docker·容器
JavaPub-rodert12 小时前
Docker 安装 MySQL 完整教程:从零部署数据库,到生产环境持久化配置
数据库·mysql·docker
努力努力再努力wz14 小时前
【Docker 入门系列】:从 Namespace、CGroup 到 LXC:理解容器运行时、rootfs 与 LXC 实战
运维·docker·容器
JavaPub-rodert15 小时前
Docker 多阶段构建:为什么生产环境镜像可以小 90%
运维·docker·容器
PC2005-cloud16 小时前
Qdrant 连接失败排查:localhost 解析到 __1,而 Docker 只绑了 IPv4
运维·docker·容器
喵喵爱自由17 小时前
Deepseek Harness镜像离线部署
docker·ai·语言模型
一技安身17 小时前
【信创】Ollama 手动提取 deepseek-r1:1.5b模型迁移到内网机器
服务器·docker·语言模型