将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
相关推荐
wazmlp00188736912 小时前
k8s pod 管理
docker·容器·kubernetes
江湖有缘12 小时前
Docker开源项目: 基于Ubuntu系统部署ExpenseOwl自托管记账工具实战教程
ubuntu·docker·开源
paopaokaka_luck12 小时前
基于springboot3+vue3的车间生产管理系统(Echarts图形化分析、BI报表)
java·前端·spring boot·学习·echarts
流星白龙14 小时前
【Docker】9.Docker 镜像仓库实战
运维·docker·容器
张洛闻Eren15 小时前
云原生k8s【第六课】:K8s 访问控制
运维·docker·云原生·容器·kubernetes·k8s
用户9385156350715 小时前
从同源策略到Nginx代理:React+NestJS全栈项目跨域实战
后端·docker
识途老码16 小时前
docker运行sqlserver
docker·容器·sqlserver
心之语歌17 小时前
Windows Docker Desktop 部署 SQL Server 2022 完整安装手册
windows·docker·容器
荔枝吻17 小时前
【保姆级喂饭教程】 Windows下WSL2+Docker+Qdrant安装教程
windows·docker·wsl2·qdrant
java_logo17 小时前
Docker 部署 TypeWords:轻松搭建英语单词与文章练习平台
运维·docker·容器·轩辕镜像·typewords·英语单词练习·四级单词练习