-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDockerfile
102 lines (95 loc) · 8.58 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
FROM ubuntu:18.04
# variables for installation
ARG SOURCE_DIR=/usr/local/src
ARG BUILD_DEPS='make cmake gcc libpcre3 libpcre3-dev zlib1g zlib1g-dev net-tools vim iptables'
ARG NGINX=nginx-1.17.1
ARG FDFS_COMMON=libfastcommon-1.0.39
ARG FDFS_NGINX=fastdfs-nginx-module-1.20
ARG FDFS=fastdfs-5.11
ARG FDHT=fastdht-master
ARG BKDB=db-4.7.25
ENV FDFS_DATA_DIR=/var/local/fdfs
ENV FDFS_CONF_DIR=/etc/fdfs
ENV FDHT_DATA_DIR=/var/local/fdht
ENV FDHT_CONF_DIR=/etc/fdht
ENV STORAGE_PORT=23000
ENV STORAGE_HTTP_PORT=8888
ENV TRACKER_PORT=22122
ENV TRACKER_HTTP_PORT=8080
ENV FDHT_PORT=11411
ENV TRACKER_HOST=127.0.0.1
ENV STORAGE_HOST=127.0.0.1
ENV IP=127.0.0.1
# copy files
COPY files/ $SOURCE_DIR
COPY entry.sh /usr/bin
################################################## all install steps ###################################################
RUN cd $SOURCE_DIR \
\
# extra files \
&& for tar in *.tar.gz; do tar -xzf $tar; done && rm *.tar.gz \
\
# copy special files to destination dir \
&& mv sources.list /etc/apt/sources.list \
&& mv fdfs /usr/bin/fdfs \
&& mkdir -p $FDFS_CONF_DIR \
&& mkdir -p $FDHT_CONF_DIR \
&& mkdir -p $FDFS_DATA_DIR/store0 \
&& mkdir -p $FDHT_DATA_DIR \
&& mv test.jpg $FDFS_CONF_DIR/test.jpg \
\
# update apt repo, install depended softwares \
&& apt-get update && apt-get install -y $BUILD_DEPS \
\
# install libfastcommon \
&& cd $SOURCE_DIR/$FDFS_COMMON && ./make.sh && ./make.sh install \
\
# install fastdfs \
&& cd $SOURCE_DIR/$FDFS && ./make.sh && ./make.sh install \
\
# fix a installation bug of fastdfs-nginx-module \
&& sed -i "s|/usr/local/include|/usr/include/fastdfs /usr/include/fastcommon|g" $SOURCE_DIR/$FDFS_NGINX/src/config \
\
# install nginx with module \
&& cd $SOURCE_DIR/$NGINX && ./configure --add-module=$SOURCE_DIR/$FDFS_NGINX/src \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--pid-path=/var/log/nginx/nginx.pid \
--http-log-path=/var/log/nginx/access.log \
&& make && make install \
\
# install Berkeley DB \
&& cd $SOURCE_DIR/$BKDB/build_unix && ../dist/configure --prefix=/usr && make && make install \
\
# install fastdht \
&& cd $SOURCE_DIR/$FDHT && ./make.sh && ./make.sh install \
\
# post installation \
\
### overwrite nginx conf file, copy fdfs and fastdfs-nginx-module conf file \
&& mv $SOURCE_DIR/nginx.conf /etc/nginx/nginx.conf \
&& cp $SOURCE_DIR/$FDFS/conf/* $FDFS_CONF_DIR \
&& cp $SOURCE_DIR/$FDFS_NGINX/src/mod_fastdfs.conf $FDFS_CONF_DIR \
\
### modify config files \
&& sed -i "s|^base_path=.*$|base_path=$FDFS_DATA_DIR|g" $FDFS_CONF_DIR/mod_fastdfs.conf \
&& sed -i "s|^base_path=.*$|base_path=$FDFS_DATA_DIR|g" $FDFS_CONF_DIR/storage.conf \
&& sed -i "s|^base_path=.*$|base_path=$FDFS_DATA_DIR|g" $FDFS_CONF_DIR/tracker.conf \
&& sed -i "s|^base_path=.*$|base_path=$FDFS_DATA_DIR|g" $FDFS_CONF_DIR/client.conf \
&& sed -i "s|^store_path0=.*$|store_path0=$FDFS_DATA_DIR/store0|g" $FDFS_CONF_DIR/storage.conf \
&& sed -i "s|^store_path0=.*$|store_path0=$FDFS_DATA_DIR/store0|g" $FDFS_CONF_DIR/mod_fastdfs.conf \
&& sed -i "s|^base_path=.*$|base_path=$FDHT_DATA_DIR|g" $FDHT_CONF_DIR/fdht_client.conf \
&& sed -i "s|^base_path=.*$|base_path=$FDHT_DATA_DIR|g" $FDHT_CONF_DIR/fdhtd.conf \
&& sed -i "4d" $FDHT_CONF_DIR/fdht_servers.conf \
&& sed -i "s|^check_file_duplicate=.*$|check_file_duplicate=1|g" $FDFS_CONF_DIR/storage.conf \
&& sed -i "s|^keep_alive=.*$|keep_alive=1|g" $FDFS_CONF_DIR/storage.conf \
&& sed -i "s|^##include.*$|#include ${FDHT_CONF_DIR}/fdht_servers.conf|g" $FDFS_CONF_DIR/storage.conf \
## remove unnecessary resources \
&& rm -rf $SOURCE_DIR/* \
&& rm -rf $FDFS_CONF_DIR/*.sample
########################################################################################################################
# expose fdfs and fdht data dir
VOLUME /var/local
EXPOSE $STORAGE_PORT $TRACKER_PORT $FDHT_PORT
ENTRYPOINT ["/usr/bin/entry.sh"]