mirror of
https://github.com/tickstep/aliyunpan.git
synced 2025-01-23 14:32:14 +08:00
add sync docker build script
This commit is contained in:
parent
86ae72f76e
commit
37f3b67002
1
.gitignore
vendored
1
.gitignore
vendored
@ -42,3 +42,4 @@ license_header.sh
|
||||
account.txt
|
||||
git_push.sh
|
||||
git_pull.sh
|
||||
docker/sync/data
|
55
docker/sync/Dockerfile
Normal file
55
docker/sync/Dockerfile
Normal file
@ -0,0 +1,55 @@
|
||||
# alpine:3.15.0
|
||||
|
||||
# 参数
|
||||
ARG DOCKER_IMAGE_HASH
|
||||
|
||||
FROM alpine@sha256:$DOCKER_IMAGE_HASH
|
||||
LABEL author="tickstep"
|
||||
LABEL email="tickstep@outlook.com"
|
||||
LABEL version="1.0"
|
||||
LABEL description="sync & backup service for aliyun cloud drive"
|
||||
|
||||
# 时区
|
||||
ENV TZ=Asia/Shanghai
|
||||
# 手动下载tzdata安装包,注意要下载对应架构的: https://dl-cdn.alpinelinux.org/alpine/v3.15/community/
|
||||
RUN apk add -U tzdata
|
||||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||
|
||||
# 创建运行目录
|
||||
RUN mkdir -p /home/app
|
||||
VOLUME /home/app
|
||||
WORKDIR /home/app
|
||||
RUN cd /home/app
|
||||
|
||||
# 创建配置文件目录
|
||||
RUN mkdir /home/app/config
|
||||
|
||||
# 创建数据文件夹
|
||||
RUN mkdir /home/app/data
|
||||
RUN chmod 777 /home/app/data
|
||||
|
||||
# 复制文件
|
||||
COPY ./docker/sync/app.sh /home/app/app.sh
|
||||
RUN chmod +x /home/app/app.sh
|
||||
|
||||
COPY ./out/binary_files/aliyunpan /home/app
|
||||
COPY ./out/binary_files/plugin /home/app/config
|
||||
COPY ./out/binary_files/sync_drive /home/app/config
|
||||
#RUN chmod +x /home/app/aliyunpan
|
||||
|
||||
# 环境变量
|
||||
ENV ALIYUNPAN_CONFIG_DIR=/home/app/config
|
||||
|
||||
ENV ALIYUNPAN_REFRESH_TOKEN=""
|
||||
ENV ALIYUNPAN_TRANSFER_URL_TYPE=0
|
||||
|
||||
ENV ALIYUNPAN_DOWNLOAD_PARALLEL=2
|
||||
ENV ALIYUNPAN_UPLOAD_PARALLEL=2
|
||||
ENV ALIYUNPAN_DOWNLOAD_BLOCK_SIZE=1024
|
||||
ENV ALIYUNPAN_UPLOAD_BLOCK_SIZE=10240
|
||||
ENV ALIYUNPAN_LOCAL_DIR=/home/app/data
|
||||
ENV ALIYUNPAN_PAN_DIR=/sync_drive
|
||||
ENV ALIYUNPAN_SYNC_MODE=upload
|
||||
|
||||
# 运行
|
||||
ENTRYPOINT ./app.sh
|
41
docker/sync/app.sh
Executable file
41
docker/sync/app.sh
Executable file
@ -0,0 +1,41 @@
|
||||
cd /home/app
|
||||
chmod +x ./aliyunpan
|
||||
|
||||
# sync config file
|
||||
readonly sync_drive_config_file="$ALIYUNPAN_CONFIG_DIR/sync_drive/sync_drive_config.json"
|
||||
if test -s $sync_drive_config_file
|
||||
then
|
||||
echo "sync_drive_config.json is existed"
|
||||
else
|
||||
echo "generate sync_drive_config.json file"
|
||||
tee $sync_drive_config_file << EOF
|
||||
{
|
||||
"configVer": "1.0",
|
||||
"syncTaskList": [
|
||||
{
|
||||
"name": "阿里云盘备份",
|
||||
"id": "5b2d7c10-e927-4e72-8f9d-5abb3bb04814",
|
||||
"localFolderPath": "$ALIYUNPAN_LOCAL_DIR",
|
||||
"panFolderPath": "$ALIYUNPAN_PAN_DIR",
|
||||
"mode": "$ALIYUNPAN_SYNC_MODE",
|
||||
"lastSyncTime": "2022-06-12 19:28:20"
|
||||
}
|
||||
]
|
||||
}
|
||||
EOF
|
||||
fi
|
||||
|
||||
sleep 2s
|
||||
|
||||
# check login already or not
|
||||
./aliyunpan who
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
echo "cache token is valid, not need to re-login"
|
||||
else
|
||||
echo "login use refresh token: ${ALIYUNPAN_REFRESH_TOKEN}"
|
||||
./aliyunpan login -RefreshToken=${ALIYUNPAN_REFRESH_TOKEN}
|
||||
fi
|
||||
|
||||
./aliyunpan config set -transfer_url_type ${ALIYUNPAN_TRANSFER_URL_TYPE}
|
||||
./aliyunpan sync start -dp ${ALIYUNPAN_DOWNLOAD_PARALLEL} -up ${ALIYUNPAN_UPLOAD_PARALLEL} -dbs ${ALIYUNPAN_DOWNLOAD_BLOCK_SIZE} -ubs ${ALIYUNPAN_UPLOAD_BLOCK_SIZE}
|
30
docker/sync/docker-compose.yml
Normal file
30
docker/sync/docker-compose.yml
Normal file
@ -0,0 +1,30 @@
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
webdav:
|
||||
image: tickstep/aliyunpan-sync:v0.1.5-amd64
|
||||
container_name: aliyunpan-sync
|
||||
restart: always
|
||||
volumes:
|
||||
- ./data:/home/app/data:rw
|
||||
environment:
|
||||
- TZ=Asia/Shanghai
|
||||
# refresh token
|
||||
- ALIYUNPAN_REFRESH_TOKEN=8bf31a...7628a8ad5a0975bf2d9
|
||||
# 上传下载链接类型:1-默认 2-阿里ECS环境
|
||||
- ALIYUNPAN_TRANSFER_URL_TYPE=1
|
||||
# 下载文件并发数
|
||||
- ALIYUNPAN_DOWNLOAD_PARALLEL=2
|
||||
# 上传文件并发数
|
||||
- ALIYUNPAN_UPLOAD_PARALLEL=2
|
||||
# 下载数据块大小,单位为KB,默认为10240KB,建议范围1024KB~10240KB
|
||||
- ALIYUNPAN_DOWNLOAD_BLOCK_SIZE=1024
|
||||
# 上传数据块大小,单位为KB,默认为10240KB,建议范围1024KB~10240KB
|
||||
- ALIYUNPAN_UPLOAD_BLOCK_SIZE=10240
|
||||
# 指定网盘文件夹作为备份目录,建议不要指定根目录
|
||||
- ALIYUNPAN_PAN_DIR=/my_sync_dir
|
||||
# 备份模式:upload(备份本地文件到云盘), download(备份云盘文件到本地), sync(双向同步备份)
|
||||
- ALIYUNPAN_SYNC_MODE=upload
|
||||
|
||||
|
||||
|
@ -29,6 +29,8 @@ COPY ./docker/webdav/app.sh /home/app/app.sh
|
||||
RUN chmod +x /home/app/app.sh
|
||||
|
||||
COPY ./out/binary_files/aliyunpan /home/app
|
||||
COPY ./out/binary_files/plugin /home/app/config
|
||||
COPY ./out/binary_files/sync_drive /home/app/config
|
||||
#RUN chmod +x /home/app/aliyunpan
|
||||
|
||||
EXPOSE 23077
|
||||
|
162
docker_sync_build.sh
Executable file
162
docker_sync_build.sh
Executable file
@ -0,0 +1,162 @@
|
||||
#!/bin/sh
|
||||
|
||||
# how to use
|
||||
# for macOS & linux, run this command in shell
|
||||
# ./docker_build.sh v0.0.1
|
||||
|
||||
name="aliyunpan"
|
||||
version=$1
|
||||
docker_image_name=tickstep/aliyunpan-sync
|
||||
|
||||
if [ "$1" = "" ]; then
|
||||
version=v1.0.0
|
||||
fi
|
||||
|
||||
# build amd64 docker
|
||||
echo "building amd64 docker image"
|
||||
ARCH=amd64
|
||||
ZIP_FILE_NAME=aliyunpan-$version-linux-$ARCH
|
||||
# use alpine:3.15.0 as base image
|
||||
# browse the url to view more information: https://hub.docker.com/layers/alpine/library/alpine/3.15.0/images/sha256-c74f1b1166784193ea6c8f9440263b9be6cae07dfe35e32a5df7a31358ac2060?context=explore
|
||||
DOCKER_IMAGE_HASH=e7d88de73db3d3fd9b2d63aa7f447a10fd0220b7cbf39803c803f2af9ba256b3
|
||||
unzip -d ./out ./out/$ZIP_FILE_NAME.zip
|
||||
mv ./out/$ZIP_FILE_NAME ./out/binary_files
|
||||
|
||||
docker build \
|
||||
-f ./docker/sync/Dockerfile \
|
||||
-t $docker_image_name:$version-$ARCH \
|
||||
--build-arg DOCKER_IMAGE_HASH=$DOCKER_IMAGE_HASH \
|
||||
--no-cache .
|
||||
|
||||
rm -rf out/binary_files
|
||||
|
||||
# build i386 docker
|
||||
echo "building i386 docker image"
|
||||
ARCH=386
|
||||
ZIP_FILE_NAME=aliyunpan-$version-linux-$ARCH
|
||||
DOCKER_IMAGE_HASH=2689e157117d2da668ad4699549e55eba1ceb79cb7862368b30919f0488213f4
|
||||
unzip -d ./out ./out/$ZIP_FILE_NAME.zip
|
||||
mv ./out/$ZIP_FILE_NAME ./out/binary_files
|
||||
|
||||
docker build \
|
||||
-f ./docker/sync/Dockerfile \
|
||||
-t $docker_image_name:$version-$ARCH \
|
||||
--build-arg DOCKER_IMAGE_HASH=$DOCKER_IMAGE_HASH \
|
||||
--no-cache .
|
||||
|
||||
rm -rf out/binary_files
|
||||
|
||||
# build arm64 docker
|
||||
echo "building arm64 docker image"
|
||||
ARCH=arm64
|
||||
ZIP_FILE_NAME=aliyunpan-$version-linux-$ARCH
|
||||
DOCKER_IMAGE_HASH=c74f1b1166784193ea6c8f9440263b9be6cae07dfe35e32a5df7a31358ac2060
|
||||
unzip -d ./out ./out/$ZIP_FILE_NAME.zip
|
||||
mv ./out/$ZIP_FILE_NAME ./out/binary_files
|
||||
|
||||
docker build \
|
||||
-f ./docker/sync/Dockerfile \
|
||||
-t $docker_image_name:$version-$ARCH \
|
||||
--build-arg DOCKER_IMAGE_HASH=$DOCKER_IMAGE_HASH \
|
||||
--no-cache .
|
||||
|
||||
rm -rf out/binary_files
|
||||
|
||||
# build armv7 docker
|
||||
echo "building armv7 docker image"
|
||||
ARCH=armv7
|
||||
ZIP_FILE_NAME=aliyunpan-$version-linux-$ARCH
|
||||
DOCKER_IMAGE_HASH=8483ecd016885d8dba70426fda133c30466f661bb041490d525658f1aac73822
|
||||
unzip -d ./out ./out/$ZIP_FILE_NAME.zip
|
||||
mv ./out/$ZIP_FILE_NAME ./out/binary_files
|
||||
|
||||
docker build \
|
||||
-f ./docker/sync/Dockerfile \
|
||||
-t $docker_image_name:$version-$ARCH \
|
||||
--build-arg DOCKER_IMAGE_HASH=$DOCKER_IMAGE_HASH \
|
||||
--no-cache .
|
||||
|
||||
rm -rf out/binary_files
|
||||
|
||||
# build armv5 docker
|
||||
echo "building armv5 docker image"
|
||||
ARCH=armv5
|
||||
ZIP_FILE_NAME=aliyunpan-$version-linux-$ARCH
|
||||
DOCKER_IMAGE_HASH=e047bc2af17934d38c5a7fa9f46d443f1de3a7675546402592ef805cfa929f9d
|
||||
unzip -d ./out ./out/$ZIP_FILE_NAME.zip
|
||||
mv ./out/$ZIP_FILE_NAME ./out/binary_files
|
||||
|
||||
docker build \
|
||||
-f ./docker/sync/Dockerfile \
|
||||
-t $docker_image_name:$version-$ARCH \
|
||||
--build-arg DOCKER_IMAGE_HASH=$DOCKER_IMAGE_HASH \
|
||||
--no-cache .
|
||||
|
||||
rm -rf out/binary_files
|
||||
#
|
||||
#echo "push docker images"
|
||||
#docker push $docker_image_name:$version-amd64
|
||||
#docker push $docker_image_name:$version-386
|
||||
#docker push $docker_image_name:$version-arm64
|
||||
#docker push $docker_image_name:$version-armv7
|
||||
#docker push $docker_image_name:$version-armv5
|
||||
#
|
||||
#echo "create docker manifest"
|
||||
#docker manifest create $docker_image_name:$version \
|
||||
#$docker_image_name:$version-amd64 \
|
||||
#$docker_image_name:$version-386 \
|
||||
#$docker_image_name:$version-arm64 \
|
||||
#$docker_image_name:$version-armv7 \
|
||||
#$docker_image_name:$version-armv5 \
|
||||
#--amend
|
||||
#
|
||||
#
|
||||
#echo "annotate manifest for amd64 image"
|
||||
#docker manifest annotate \
|
||||
#--arch=amd64 \
|
||||
#--os=linux \
|
||||
#$docker_image_name:$version \
|
||||
#$docker_image_name:$version-amd64
|
||||
#
|
||||
#echo "annotate manifest for 386 image"
|
||||
#docker manifest annotate \
|
||||
#--arch=386 \
|
||||
#--os=linux \
|
||||
#$docker_image_name:$version \
|
||||
#$docker_image_name:$version-386
|
||||
#
|
||||
#echo "annotate manifest for arm64 image"
|
||||
#docker manifest annotate \
|
||||
#--arch=arm64 \
|
||||
#--os=linux \
|
||||
#--variant=v8 \
|
||||
#$docker_image_name:$version \
|
||||
#$docker_image_name:$version-arm64
|
||||
#
|
||||
#echo "annotate manifest for armv7 image"
|
||||
#docker manifest annotate \
|
||||
#--arch=arm \
|
||||
#--os=linux \
|
||||
#--variant=v7 \
|
||||
#$docker_image_name:$version \
|
||||
#$docker_image_name:$version-armv7
|
||||
#
|
||||
#echo "annotate manifest for armv5 image"
|
||||
#docker manifest annotate \
|
||||
#--arch=arm \
|
||||
#--os=linux \
|
||||
#--variant=v6 \
|
||||
#$docker_image_name:$version \
|
||||
#$docker_image_name:$version-armv5
|
||||
#
|
||||
#echo "push manifest to docker hub"
|
||||
#docker manifest push $docker_image_name:$version
|
||||
#
|
||||
#echo "clear local docker image"
|
||||
#docker rmi $docker_image_name:$version-amd64
|
||||
#docker rmi $docker_image_name:$version-386
|
||||
#docker rmi $docker_image_name:$version-arm64
|
||||
#docker rmi $docker_image_name:$version-armv7
|
||||
#docker rmi $docker_image_name:$version-armv5
|
||||
|
||||
echo "ALL DONE"
|
Loading…
Reference in New Issue
Block a user