Skip to content

Commit

Permalink
fastdfs合并镜像
Browse files Browse the repository at this point in the history
  • Loading branch information
Felix2yu committed Feb 21, 2024
1 parent 498c771 commit 09ca4ad
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 56 deletions.
44 changes: 17 additions & 27 deletions fastdfs/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,4 @@
FROM debian:stable as builder

ENV FASTDFS_PATH=/opt/fdfs \
FASTDFS_BASE_PATH=/data/fdfs \
LIBFASTCOMMON_VERSION="V1.0.42" \
FASTDFS_VERSION="V5.12"

WORKDIR ${FASTDFS_PATH}
RUN apt-get update && \
apt-get install -y git gcc make

RUN git clone -b $LIBFASTCOMMON_VERSION https://github.com/happyfish100/libfastcommon.git && \
cd libfastcommon && \
./make.sh

RUN git clone -b $FASTDFS_VERSION https://github.com/happyfish100/fastdfs.git && \
cd fastdfs && \
./make.sh

FROM debian:stable-slim
FROM debian:stable

LABEL org.opencontainers.image.source = "https://github.com/Felix2yu/docker_build" \
maintainer="Felix2yu <yufei.im@icloud.com>" \
Expand All @@ -26,18 +7,27 @@ LABEL org.opencontainers.image.source = "https://github.com/Felix2yu/docker_buil
ENV FASTDFS_PATH=/opt/fdfs \
FASTDFS_BASE_PATH=/data/fdfs \
TZ=Asia/Shanghai \
FASTDFS_MODE=
FASTDFS_MODE= \
LIBFASTCOMMON_VERSION="V1.0.42" \
FASTDFS_VERSION="V5.12"

COPY --from=builder ${FASTDFS_PATH} ${FASTDFS_PATH}
COPY entrypoint.sh /usr/bin/

RUN chmod +x /usr/bin/entrypoint.sh && \
apt-get update && \
apt-get install -y --no-install-recommends make && \
cd ${FASTDFS_PATH}/libfastcommon && ./make.sh install && \
cd ${FASTDFS_PATH}/fastdfs && ./make.sh install && \
mkdir -p ${FASTDFS_BASE_PATH} && \
apt-get clean -y && rm -rf /var/lib/apt/lists/* /var/cache/apt
apt-get install -y git gcc make && \
mkdir -p ${FASTDFS_BASE_PATH} ${FASTDFS_PATH}/libfastcommon ${FASTDFS_PATH}/fastdfs && \
git clone -b $LIBFASTCOMMON_VERSION https://github.com/happyfish100/libfastcommon.git ${FASTDFS_PATH}/libfastcommon && \
cd ${FASTDFS_PATH}/libfastcommon && \
./make.sh && \
./make.sh install && \
git clone -b $FASTDFS_VERSION https://github.com/happyfish100/fastdfs.git ${FASTDFS_PATH}/fastdfs && \
cd ${FASTDFS_PATH}/fastdfs && \
./make.sh && \
./make.sh install && \
apt-get autoremove -y git gcc make && \
apt-get clean -y && \
rm -rf /var/lib/apt/lists/* /var/cache/apt

EXPOSE 22122 23000
VOLUME ["$FASTDFS_BASE_PATH","/etc/fdfs"]
Expand Down
39 changes: 10 additions & 29 deletions fastdfs/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@ function fdfs_start() {
PID_NUMBER="${FASTDFS_BASE_PATH}/data/fdfs_${FASTDFS_MODE}d.pid"

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

# start the fastdfs node.
#rm -f "$FASTDFS_LOG_FILE"
rm -f "$PID_NUMBER"
fdfs_${FASTDFS_MODE}d /etc/fdfs/${FASTDFS_MODE}.conf start
TIMES=30
while [ ! -f "$PID_NUMBER" -a $TIMES -gt 0 ]
do
sleep 1s
TIMES=`expr $TIMES - 1`
done

tail -f "$FASTDFS_LOG_FILE"
}

function health_check() {
Expand All @@ -42,29 +43,9 @@ if [ "$1" = "monitor" ] ; then
exit 0
elif [ "$FASTDFS_MODE" = "storage" ] ; then
fdfs_start
health_check &
elif [ "$FASTDFS_MODE" = "tracker" ] ; then
fdfs_start
health_check &
else
echo "No mode parameters were received."
exit 1
fi

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

case $1 in
monitor|storage|tracker)
# sleep infinity
[ -f "$FASTDFS_LOG_FILE" ] && tail -f "$FASTDFS_LOG_FILE"
;;
*)
exec "$@"
;;
esac

0 comments on commit 09ca4ad

Please sign in to comment.