update
This commit is contained in:
20
centos7/Dockerfile
Normal file
20
centos7/Dockerfile
Normal file
@@ -0,0 +1,20 @@
|
||||
FROM centos:7.9.2009
|
||||
MAINTAINER Colben colbenlee@gmail.com
|
||||
ARG ARCH
|
||||
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
|
||||
&& rm -f /etc/yum.repos.d/CentOS-* \
|
||||
&& echo -e "[centos7]\n\
|
||||
name=centos base\n\
|
||||
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos${ARCH:+-altarch}/$releasever/os/$basearch/\n\
|
||||
enabled=1\n\
|
||||
gpgcheck=0\n\
|
||||
" > /etc/yum.repos.d/centos7.repo \
|
||||
&& yum makecache fast \
|
||||
&& yum update -y \
|
||||
&& yum -y install less iproute \
|
||||
&& rm -rf /var/cache/yum \
|
||||
&& 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
|
||||
|
7
centos7/README.md
Normal file
7
centos7/README.md
Normal file
@@ -0,0 +1,7 @@
|
||||
# 构建 centos7 镜像
|
||||
|
||||
## 定制
|
||||
- 使用 Asia/Shanghai 时区
|
||||
- 安装 less iproute
|
||||
- 默认语言 en_US.UTF-8
|
||||
|
67
centos7/centos.sh
Executable file
67
centos7/centos.sh
Executable file
@@ -0,0 +1,67 @@
|
||||
#!/bin/bash
|
||||
|
||||
#=========================================
|
||||
# Author : colben
|
||||
#=========================================
|
||||
|
||||
set -euo pipefail
|
||||
export LANG=en_US.UTF-8
|
||||
trap Quit EXIT
|
||||
|
||||
[ 'x86_64' == "$(uname -m)" ] && ARCH='' || ARCH="-$(uname -m)"
|
||||
ROOT_DIR="$(cd $(dirname $0) && pwd)"
|
||||
IMAGE="harbor.colben.cn/general/$(basename ${0%.sh})$ARCH:7"
|
||||
|
||||
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 {
|
||||
:
|
||||
}
|
||||
|
||||
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 --build-arg ARCH="$ARCH" -t $IMAGE .
|
||||
YesOrNo Push image: $IMAGE? && docker push $IMAGE
|
||||
}
|
||||
|
||||
function Main {
|
||||
Update
|
||||
Build
|
||||
END=1
|
||||
}
|
||||
|
||||
# Start here
|
||||
Main
|
||||
|
Reference in New Issue
Block a user