-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
162 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: fastdfs docker镜像构建 | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- 'main' | ||
paths: | ||
- 'fastdfs/**' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
uses: actions/checkout@v4 | ||
- | ||
name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: | | ||
felix2yu/fastdfs | ||
ghcr.io/felix2yu/fastdfs | ||
tags: | | ||
type=raw,value=latest | ||
type=schedule,pattern={{date 'YYYYMMDD'}} | ||
- | ||
name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
- | ||
name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- | ||
name: Login to DockerHub | ||
if: github.event_name != 'pull_request' | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- | ||
name: Login to GHCR | ||
if: github.event_name != 'pull_request' | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.REGISTRY_TOKEN }} | ||
- | ||
name: Build and push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: ./fastdfs | ||
platforms: linux/amd64 | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
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 | ||
|
||
LABEL org.opencontainers.image.source = "https://github.com/Felix2yu/docker_build" \ | ||
maintainer="Felix2yu <yufei.im@icloud.com>" \ | ||
org.opencontainers.image.authors="Felix2yu <yufei.im@icloud.com>" | ||
|
||
ENV FASTDFS_PATH=/opt/fdfs \ | ||
FASTDFS_BASE_PATH=/data/fdfs \ | ||
TZ=Asia/Shanghai | ||
|
||
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 | ||
|
||
EXPOSE 22122 23000 | ||
|
||
ENTRYPOINT ["/usr/bin/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
自用镜像,配置文件需要自备,挂载到`/etc/fdfs/`,数据`FASTDFS_BASE_PATH`默认存储到`/data/fdfs` | ||
fastdfs:V5.12 | ||
libfastcommon:V1.0.42 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/bin/bash | ||
#set -e | ||
|
||
function fdfs_start() { | ||
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..." | ||
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. | ||
fdfs_${FASTDFS_MODE}d /etc/fdfs/${FASTDFS_MODE}.conf start | ||
} | ||
|
||
function health_check() { | ||
if [ $HOSTNAME = "localhost.localdomain" ]; then | ||
return 0 | ||
fi | ||
# Storage OFFLINE, restart storage. | ||
monitor_log=/tmp/monitor.log | ||
check_log=/tmp/health_check.log | ||
while true; do | ||
fdfs_monitor /etc/fdfs/client.conf 1>$monitor_log 2>&1 | ||
cat $monitor_log|grep $HOSTNAME > $check_log 2>&1 | ||
error_log=$(egrep "OFFLINE" "$check_log") | ||
if [ ! -z "$error_log" ]; then | ||
cat /dev/null > "$FASTDFS_LOG_FILE" | ||
fdfs_start | ||
fi | ||
sleep 10 | ||
done | ||
} | ||
|
||
fdfs_start | ||
health_check & | ||
|
||
# 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 |