update
This commit is contained in:
		
							
								
								
									
										26
									
								
								rocky/Dockerfile-8
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								rocky/Dockerfile-8
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,26 @@
 | 
			
		||||
FROM            rockylinux/rockylinux:8-minimal
 | 
			
		||||
MAINTAINER      Colben colbenlee@gmail.com
 | 
			
		||||
RUN             ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
 | 
			
		||||
                    && rm -f /etc/yum.repos.d/* \
 | 
			
		||||
                    && echo -e '[AppStream]\n\
 | 
			
		||||
name=Rocky-$releasever - AppStream\n\
 | 
			
		||||
baseurl=https://mirrors.ustc.edu.cn/rocky/$releasever/AppStream/$basearch/os/\n\
 | 
			
		||||
enabled=1\n\
 | 
			
		||||
gpgcheck=0\n\
 | 
			
		||||
\n\
 | 
			
		||||
[BaseOS]\n\
 | 
			
		||||
name=Rocky-$releasever - Base\n\
 | 
			
		||||
baseurl=https://mirrors.ustc.edu.cn/rocky/$releasever/BaseOS/$basearch/os/\n\
 | 
			
		||||
enabled=1\n\
 | 
			
		||||
gpgcheck=0\n\
 | 
			
		||||
' > /etc/yum.repos.d/rocky.repo \
 | 
			
		||||
                    && microdnf makecache \
 | 
			
		||||
                    && microdnf install ncurses iproute procps-ng glibc-langpack-en findutils less pam tar \
 | 
			
		||||
                    && echo 'alias ls="ls --color=auto"' > /etc/profile.d/docker.sh \
 | 
			
		||||
                    && rm -rf /var/cache/yum /var/lib/dnf \
 | 
			
		||||
                    && rm -rf /var/log/*
 | 
			
		||||
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
 | 
			
		||||
ENV             LC_ALL=en_US.UTF-8
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										10
									
								
								rocky/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								rocky/README.md
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,10 @@
 | 
			
		||||
# 构建 rockylinux 8 镜像
 | 
			
		||||
 | 
			
		||||
## 导入文件
 | 
			
		||||
- 本机时区 /etc/localtime
 | 
			
		||||
 | 
			
		||||
## 定制
 | 
			
		||||
- 使用 Asia/Shanghai 时区
 | 
			
		||||
- 安装 ncurses iproute
 | 
			
		||||
- 默认语言 en_US.UTF-8
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										72
									
								
								rocky/rocky.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										72
									
								
								rocky/rocky.sh
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,72 @@
 | 
			
		||||
#!/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)"
 | 
			
		||||
TAG=$1
 | 
			
		||||
IMAGE="harbor.colben.cn/general/$(basename ${0%.sh})$ARCH:$TAG"
 | 
			
		||||
 | 
			
		||||
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=$?
 | 
			
		||||
    rm -f Dockerfile
 | 
			
		||||
    [ 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
 | 
			
		||||
    mkdir -p ADD && 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 ...
 | 
			
		||||
    ln -sf Dockerfile-$TAG Dockerfile
 | 
			
		||||
    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
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user