将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
相关推荐
月清晖18 分钟前
centos更换yum源、安装Docker和换源
linux·docker·centos
Mark White2 小时前
软连接迁移 Docker 的默认安装(存储)目录
docker
java小郭5 小时前
Docker系列-Docker镜像分层原理
运维·docker·容器
无言非影10 小时前
【echarts】拖拽滑块dataZoom-slider自定义样式,简单适配移动端
前端·javascript·echarts
无极低码13 小时前
用网上抓取的天气的接口做了一个系统
java·前端·数据库·网络爬虫·echarts·天气·数据资源
kali-Myon13 小时前
基于Cardinal的AWD攻防平台搭建与使用以及基于docker的题目环境部署
运维·学习·mysql·web安全·docker·容器·awd
孤城28618 小时前
03 Docker 常用镜像命令
docker·云原生·容器·devops
新时代的弩力18 小时前
docker配置redis主从复制
redis·docker·容器
嫣然细雨红尘路19 小时前
Docker学习笔记(一)概念理解
笔记·学习·docker
孤城28621 小时前
05 docker 镜像
运维·docker·容器