编程开源技术交流,分享技术与知识

网站首页 > 开源技术 正文

dockerfile制作一个容器运行多个程序openoffice服务的预览服务

wxchong 2024-08-30 04:01:48 开源技术 13 ℃ 0 评论

应用场景

1.实现一个容器中运行多个进程

2.应用与一个容器中的一个程序依赖另一个应用程序,需要将多个程序制作在一个镜像中


实现技术方法

  1. dockerfile
  2. docker
  3. supervisor
  4. openoffice
  5. tomcat服务(jar包)

openoffice下载


下载地址如下:

官网:https://www.openoffice.org/zh-cn/

官方安装包下载地址: https://www.openoffice.org/zh-cn/download/index.html

非docker安装官方示例: https://www.openoffice.org/zh-cn/download/common/instructions.html

注意问题:

依赖包: yum install libXext.x86_64 && yum -y groupinstall "X Window System"

supervisor安装

基于centos服务器

yum install supervisor

配置文件准备:

supervisord.conf(可根据自己实际情况进行添加)

[unix_http_server]
file=/var/run/supervisor/supervisor.sock   ; (the path to the socket file)


[supervisord]
logfile=/var/log/supervisor/supervisord.log  ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB       ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10          ; (num of main logfile rotation backups;default 10)
loglevel=info               ; (log level;default info; others: debug,warn,trace)
user=root
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=true              ; (start in foreground if true;default false)
minfds=1024                 ; (min. avail startup file descriptors;default 1024)
minprocs=200                ; (min. avail process descriptors;default 200)

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=unix:///var/run/supervisor/supervisor.sock ; use a unix:// URL  for a unix socket


[program:openoffice]
directory=/opt/openoffice4/program
command=soffice -headless -accept="socket,host=0.0.0.0,port=8100;urp;" -nofirststartwizard
autostart=true
startsecs=60
autorestart=true
startretries=3
user=root
redirect_stderr=true

[program:test-system]
directory=/opt
command=java -server -Djava.security.egd=file:/dev/./urandom -jar /opt/test.jar
autostart=true
startsecs=120
autorestart=true
startretries=3
user=root
redirect_stderr=true


Dockerfile镜像制作

dockerfile文件如下:

FROM test/dev/centos-oracle-java8:v1.0.1  //centos基本镜像带有jdk的业务版本
MAINTAINER wade.qu <wade.qu@fosun.com
ENV LANG=en_US.UTF-8
RUN  yum -y install epel-release && yum clean all && yum install -y supervisor tzdata libXext.x86_64  && yum -y groupinstall "X Window System"\
    && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
    && echo "Asia/Shanghai" > /etc/timezone

ARG appname
ARG jarname
ENV appname ${appname}

#USER jpaas

#工作目录
WORKDIR /opt

#暴露端口
EXPOSE 7009
ADD Apache_OpenOffice_4.1.14_Linux_x86-64_install-rpm_zh-CN.tar.gz .
COPY supervisord.conf /etc/supervisord.conf
COPY libXext.so.6 /opt/openoffice4/program/
RUN yum makecache && yum -y localinstall zh-CN/RPMS/*.rpm && yum -y localinstall zh-CN/RPMS/desktop-integration/openoffice4.1.14-redhat-menus-4.1.14-9811.noarch.rpm && mkdir -p /opt/filedata && rm -fr zh-CN
ADD ${jarname} /opt/${appname}.jar
CMD ["/usr/bin/supervisord","-c","/etc/supervisord.conf"]


制作镜像

docker build --build-arg appname="服务名称" --build-arg jarname="jar包名称" -t testdev/test:1.1.8 .



完成

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表