Skip to content

Commit

Permalink
add fastdfsV5.05
Browse files Browse the repository at this point in the history
  • Loading branch information
liujie-666 committed Dec 11, 2024
1 parent ec4281b commit 338460a
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 0 deletions.
26 changes: 26 additions & 0 deletions delron/fastdfs/5.05/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM cr.loongnix.cn/openanolis/anolisos:8.9
LABEL org.label-schema.schema-version==1.0 org.label-schema.license=GPLv2
CMD ["/bin/bash"]
LABEL [email protected]
ENV FASTDFS_PATH=/opt/fdfs FASTDFS_BASE_PATH=/var/fdfs PORT= GROUP_NAME= TRACKER_SERVER=
RUN /bin/sh -c "dnf install -y wget zlib zlib-devel pcre pcre-devel gcc gcc-c++ openssl openssl-devel libevent libevent-devel perl unzip net-tools git make"
RUN /bin/sh -c "mkdir -p ${FASTDFS_PATH}/libfastcommon && mkdir -p ${FASTDFS_PATH}/fastdfs && mkdir ${FASTDFS_BASE_PATH}"
WORKDIR /opt/fdfs/libfastcommon
ADD src/libfastcommon ${FASTDFS_PATH}/libfastcommon
RUN ./make.sh && ./make.sh install && rm -rf ${FASTDFS_PATH}/libfastcommon
WORKDIR /opt/fdfs/fastdfs
ADD src/fastdfs ${FASTDFS_PATH}/fastdfs
RUN ./make.sh && ./make.sh install && rm -rf ${FASTDFS_PATH}/fastdfs
EXPOSE 22122 23000 8080 8888
VOLUME ["/var/fdfs", "/etc/fdfs"]
RUN mkdir -p /tmp/nginx
ADD src/nginx /tmp/nginx/nginx
COPY src/nginx_module /tmp/nginx/nginx_module
WORKDIR /tmp/nginx/nginx
RUN ./auto/configure --prefix=/usr/local/nginx --add-module=/tmp/nginx/nginx_module/src && make && make install
COPY src/nginx/conf/ /etc/fdfs/
RUN ls -al /usr/local/nginx/conf
COPY start1.sh /usr/bin/
RUN chmod 777 /usr/bin/start1.sh
ENTRYPOINT ["/usr/bin/start1.sh"]
CMD ["tracker"]
34 changes: 34 additions & 0 deletions delron/fastdfs/5.05/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

REGISTRY?=cr.loongnix.cn
ORGANIZATION?=calico
REPOSITORY?=fastdfs
TAG?=5.05

FASTDFS_SRC_URL=https://github.com/liujie-666/fastdfs.git
NGINX_SRC_URL=https://github.com/nginx/nginx.git
NGINX_MODULE_URL=https://github.com/happyfish100/fastdfs-nginx-module.git
LIBFAST_COMMON_SRC_URL=https://github.com/happyfish100/libfastcommon.git

NGINX_COMMIT=0ddad64
NGINX_MODULE_COMMIT=10d1729
LIBFAST_COMMON_COMMIT=906c9e8

IMAGE_NAME=$(REGISTRY)/$(ORGANIZATION)/$(REPOSITORY):$(TAG)
SUBDIR = fastdfs nginx nginx_module libfastcommon

default:image

image: $(foreach dir, $(SUBDIR), src/$(dir))
docker build -t $(IMAGE_NAME) .
src/fastdfs:
git clone $(FASTDFS_SRC_URL) $@
src/nginx:
git clone $(NGINX_SRC_URL) $@ && cd $@ && git checkout ${NGINX_COMMITI}
src/nginx_module:
git clone $(NGINX_MODULE_URL) $@ && cd $@ && git checkout ${NGINX_MODULE_COMMIT}
src/libfastcommon:
git clone $(LIBFAST_COMMON_SRC_URL) $@ && cd $@ && git checkout ${LIBFAST_COMMON_COMMIT}
push:
docker push $(IMAGE_NAME)
clean:
rm -rf src
76 changes: 76 additions & 0 deletions delron/fastdfs/5.05/start1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/bin/bash
#set -e
if [ "$1" = "monitor" ] ; then
if [ -n "$TRACKER_SERVER" ] ; then
sed -i "s|tracker_server=.*$|tracker_server=${TRACKER_SERVER}|g" /etc/fdfs/client.conf
fi
fdfs_monitor /etc/fdfs/client.conf
exit 0
elif [ "$1" = "storage" ] ; then
FASTDFS_MODE="storage"
sed -i "s|store_path0.*$|store_path0=/var/fdfs|g" /etc/fdfs/mod_fastdfs.conf
sed -i "s|url_have_group_name =.*$|url_have_group_name = true|g" /etc/fdfs/mod_fastdfs.conf
/usr/local/nginx/sbin/nginx
else
FASTDFS_MODE="tracker"
fi

if [ -n "$PORT" ] ; then
sed -i "s|^port=.*$|port=${PORT}|g" /etc/fdfs/"$FASTDFS_MODE".conf
fi

if [ -n "$TRACKER_SERVER" ] ; then

sed -i "s|tracker_server=.*$|tracker_server=${TRACKER_SERVER}|g" /etc/fdfs/storage.conf
sed -i "s|tracker_server=.*$|tracker_server=${TRACKER_SERVER}|g" /etc/fdfs/client.conf
sed -i "s|tracker_server=.*$|tracker_server=${TRACKER_SERVER}:22122|g" /etc/fdfs/mod_fastdfs.conf

fi

if [ -n "$GROUP_NAME" ] ; then

sed -i "s|group_name=.*$|group_name=${GROUP_NAME}|g" /etc/fdfs/storage.conf

fi

FASTDFS_LOG_FILE="${FASTDFS_BASE_PATH}/logs/${FASTDFS_MODE}d.log"
PID_NUMBER="${FASTDFS_BASE_PATH}/data/fdfs_${FASTDFS_MODE}d.pid"

echo "try to start the $FASTDFS_MODE node..."
if [ -f "$FASTDFS_LOG_FILE" ]; then
rm "$FASTDFS_LOG_FILE"
fi
# start the fastdfs node.
fdfs_${FASTDFS_MODE}d /etc/fdfs/${FASTDFS_MODE}.conf start

# wait for pid file(important!),the max start time is 5 seconds,if the pid number does not appear in 5 seconds,start failed.
TIMES=5
while [ ! -f "$PID_NUMBER" -a $TIMES -gt 0 ]
do
sleep 1s
TIMES=`expr $TIMES - 1`
done

# if the storage node start successfully, print the started time.
# if [ $TIMES -gt 0 ]; then
# echo "the ${FASTDFS_MODE} node started successfully at $(date +%Y-%m-%d_%H:%M)"

# # give the detail log address
# echo "please have a look at the log detail at $FASTDFS_LOG_FILE"

# # leave balnk lines to differ from next log.
# echo
# echo



# # make the container have foreground process(primary commond!)
# tail -F --pid=`cat $PID_NUMBER` /dev/null
# # else print the error.
# else
# echo "the ${FASTDFS_MODE} node started failed at $(date +%Y-%m-%d_%H:%M)"
# echo "please have a look at the log detail at $FASTDFS_LOG_FILE"
# echo
# echo
# fi
tail -f "$FASTDFS_LOG_FILE"

0 comments on commit 338460a

Please sign in to comment.