From fc79d5d3506ff9094225cd83efddd7c3271dbbe5 Mon Sep 17 00:00:00 2001 From: colben Date: Wed, 31 Jan 2024 18:06:16 +0800 Subject: [PATCH] update --- alpine-3.12/Dockerfile | 14 +++++++ alpine-3.12/README.md | 11 ++++++ alpine-3.12/alpine.sh | 69 +++++++++++++++++++++++++++++++++ redis/Demo/SingleNode/README.md | 2 +- redis/Demo/SixNodes/README.md | 2 +- redis/Demo/ThreeNodes/README.md | 2 +- rsync/ADD/ccmd | 4 +- rsync/Dockerfile | 4 +- rsync/rsync.sh | 2 +- 9 files changed, 102 insertions(+), 8 deletions(-) create mode 100644 alpine-3.12/Dockerfile create mode 100644 alpine-3.12/README.md create mode 100755 alpine-3.12/alpine.sh diff --git a/alpine-3.12/Dockerfile b/alpine-3.12/Dockerfile new file mode 100644 index 0000000..f6e3033 --- /dev/null +++ b/alpine-3.12/Dockerfile @@ -0,0 +1,14 @@ +FROM alpine:3.12 +MAINTAINER Colben colbenlee@gmail.com +ADD --chown=root:root /ADD/ /etc/ +RUN echo -e 'https://mirrors.tuna.tsinghua.edu.cn/alpine/v3.12/main\n\ +https://mirrors.tuna.tsinghua.edu.cn/alpine/v3.12/community\n\ +' > /etc/apk/repositories \ + && apk update \ + && apk add --no-cache bash curl coreutils iproute2 \ + && echo "alias ls='ls --color=auto'" >> /root/.bashrc \ + && rm -rf /var/cache/apk/* +ENV PS1='\[\e[33;1;1m\][\[\e[0m\]\[\e[35;1m\]\u\[\e[0m\]\[\e[33;1;1m\]@\[\e[0m\]\[\e[31;1;1m\]docker\[\e[0m\]\[\e[32;1;1m\](\h)\[\e[0m\]\[\e[33;1;1m\]:\[\e[0m\]\[\e[32m\]\w\[\e[0m\]\[\e[33;1;1m\]]\[\e[0m\]\[\e[36m\]\$\[\e[0m\] ' +ENV PS2='\[\e[36m\]>\[\e[0m\] ' +ENV LANG=en_US.UTF-8 + diff --git a/alpine-3.12/README.md b/alpine-3.12/README.md new file mode 100644 index 0000000..26d5d4e --- /dev/null +++ b/alpine-3.12/README.md @@ -0,0 +1,11 @@ +# 构建 alpine 镜像 + +## 导入文件 +- 本机时区 /etc/localtime + +## 定制 +- 使用 Asia/Shanghai 时区 +- 修改软件源,开启 edge +- 安装 bash curl coreutils iproute2 +- 默认语言 en_US.UTF-8 + diff --git a/alpine-3.12/alpine.sh b/alpine-3.12/alpine.sh new file mode 100755 index 0000000..0a6b2d9 --- /dev/null +++ b/alpine-3.12/alpine.sh @@ -0,0 +1,69 @@ +#!/bin/bash + +#========================================= +# Author : colben +#========================================= + +set -euo pipefail +export LANG=en_US.UTF-8 + +[ 'x86_64' == "$(uname -m)" ] && ARCH='' || ARCH="-$(uname -m)" +ROOT_DIR="$(cd $(dirname $0) && pwd)" +IMAGE="harbor.colben.cn/general/$(basename ${0%.sh})$ARCH:3.12" + +if [ -t 0 ]; then + function Print { echo -e "\033[36;1m$(date +'[%F %T]')\033[32;1m $*\033[0m"; } + function Warn { echo -e "\033[36;1m$(date +'[%F %T]')\033[33;1m $*\033[0m"; } + function Error { echo -e "\033[36;1m$(date +'[%F %T]')\033[31;1m $*\033[0m"; exit 1; } +else + function Print { echo -e "$(date +'[%F %T INFO]') $*"; } + function Warn { echo -e "$(date +'[%F %T WARN]') $*"; } + function Error { echo -e "$(date +'[%F %T ERROR]') $*"; exit 1; } +fi + +function Quit { + local exitCode=$? + [ 0 -ne $exitCode ] && Error Failed to build or push image! + [ -z "${END:-}" ] && echo && Error Interrupted manually! + Print Succeeded to build and push image. +} + +function YesOrNo { + Warn $* + local sw= + while :; do + read -p '(Yes/No/Quit) ' -n1 sw + [[ "$sw" =~ ^Y|y$ ]] && echo && return 0 + [[ "$sw" =~ ^N|n$ ]] && echo && return 1 + [[ "$sw" =~ ^Q|q$ ]] && echo && exit 0 + [ -n "$sw" ] && echo + done +} + +function Update { + Warn Preparing localtime ... + cd $ROOT_DIR + cp -f /etc/localtime ADD/ +} + +function Build { + local yn + cd $ROOT_DIR + docker images --format='{{.Repository}}:{{.Tag}}' | grep "^$IMAGE$" \ + && Warn Removing image $IMAGE ... \ + && docker rmi $IMAGE + Warn Building image: $IMAGE ... + docker build --force-rm -t $IMAGE . + YesOrNo Push image: $IMAGE? && docker push $IMAGE +} + +function Main { + trap Quit EXIT + Update + Build + END=1 +} + +# Start here +Main + diff --git a/redis/Demo/SingleNode/README.md b/redis/Demo/SingleNode/README.md index 872a65e..69422d6 100644 --- a/redis/Demo/SingleNode/README.md +++ b/redis/Demo/SingleNode/README.md @@ -5,7 +5,7 @@ - 创建目录 ``` - grep '\> $LOG_DIR/rsyncd.out & PIDS="$PIDS $!" Print Rsync started. diff --git a/rsync/Dockerfile b/rsync/Dockerfile index 1c2e4aa..58b90ff 100644 --- a/rsync/Dockerfile +++ b/rsync/Dockerfile @@ -1,9 +1,9 @@ ARG ARCH -FROM harbor.colben.cn/general/alpine$ARCH +FROM harbor.colben.cn/general/alpine$ARCH:3.12 MAINTAINER Colben colbenlee@gmail.com ADD --chown=root:root /ADD/ /opt/ RUN apk update \ - && apk add --no-cache rsync \ + && apk add --no-cache rsync inotify-tools \ && mkdir -p /var/log/rsync \ && rm -rf /var/cache/apk/* CMD ["/opt/ccmd"] diff --git a/rsync/rsync.sh b/rsync/rsync.sh index 7c036fd..c72e0c8 100755 --- a/rsync/rsync.sh +++ b/rsync/rsync.sh @@ -9,7 +9,7 @@ export LANG=en_US.UTF-8 [ 'x86_64' == "$(uname -m)" ] && ARCH='' || ARCH="-$(uname -m)" ROOT_DIR="$(cd $(dirname $0) && pwd)" -IMAGE="harbor.colben.cn/general/$(basename ${0%.sh})$ARCH:latest" +IMAGE="harbor.colben.cn/general/$(basename ${0%.sh})$ARCH:3.1.3" if [ -t 0 ]; then function Print { echo -e "\033[36;1m$(date +'[%F %T]')\033[32;1m $*\033[0m"; }