码迷,mamicode.com
首页 > 其他好文 > 详细

fastdfs 构建docker镜像

时间:2020-03-31 19:12:47      阅读:71      评论:0      收藏:0      [点我收藏+]

标签:ast   启动命令   type   entry   else   sha   pen   ++   vol   

目录结构
[root@fastdfs]# tree .
.
├── conf
│?? ├── client.conf
│?? ├── http.conf
│?? ├── mime.types
│?? ├── mod_fastdfs.conf
│?? ├── nginx.conf
│?? ├── storage.conf
│?? └── tracker.conf
├── Dockerfile
├── fastdfs.sh
└── source
    ├── fastdfs-nginx-module.tar.gz
    ├── fastdfs.tar.gz
    ├── libfastcommon.tar.gz
    └── nginx-1.15.4.tar.gz

2 directories, 13 files

编写dockerfile,可以自定义启动项目

FROM centos:7.7.1908
LABEL app.maintainer=foxchan
LABEL app.version="v6.06"

RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo ‘Asia/Shanghai‘ >/etc/timezone

ENV libfastcommon V1.0.43
ENV fastdfs V6.06
ENV fastdfs-nginx-module V1.22

ADD fastdfs.sh /home
ADD source/libfastcommon.tar.gz /usr/local/src/
ADD source/fastdfs.tar.gz /usr/local/src/
ADD source/fastdfs-nginx-module.tar.gz /usr/local/src/
ADD source/nginx-1.15.4.tar.gz /usr/local/src/

# run
RUN yum install git gcc gcc-c++ make automake autoconf libtool pcre pcre-devel zlib zlib-devel openssl-devel wget vim -y   &&    mkdir -p /data/dfs/{tracker,storage}   &&    cd /usr/local/src/   &&    cd libfastcommon-1.0.43/     &&    ./make.sh && ./make.sh install    &&    cd ../    &&    cd fastdfs-6.06/     &&    ./make.sh && ./make.sh install    &&    cd ../    &&    cd nginx-1.15.4/    &&    ./configure --add-module=/usr/local/src/fastdfs-nginx-module-1.22/src/    &&    make && make install    &&    chmod +x /home/fastdfs.sh

VOLUME /etc/fdfs

VOLUME /data/dfs

ENTRYPOINT /home/fastdfs.sh && /bin/bash

启动脚本

#!/bin/bash
#Date: 2020-03-11
#Writer: foxchan

mv /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.t
cp /etc/fdfs/nginx.conf /usr/local/nginx/conf

if [ "$role" == "tracker" ];then 

   echo "start trackerd"
   /etc/init.d/fdfs_trackerd start

elif [ "$role" == "storage" ];then
   echo "start storaged"
   /etc/init.d/fdfs_storaged start

   echo "start nginx"
   /usr/local/nginx/sbin/nginx 

else 
    echo -e "Usage: role [tracker | storage]"
fi

启动命令

docker run -dit --net=host -e role=tracker -v /data/dfs/conf:/etc/fdfs/ -v /data/dfs:/data/dfs --name tracker fastdfs:v6.06
docker run -dit --net=host -e role=storage -v /data/dfs/conf:/etc/fdfs/ -v /data/dfs:/data/dfs --name storage fastdfs:v6.06

fastdfs 构建docker镜像

标签:ast   启动命令   type   entry   else   sha   pen   ++   vol   

原文地址:https://blog.51cto.com/foxhound/2483551

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!