This commit is contained in:
2022-04-18 11:21:20 +08:00
commit 45a7af638f
210 changed files with 8997 additions and 0 deletions

23
ubuntu/Dockerfile Normal file
View File

@@ -0,0 +1,23 @@
FROM ubuntu:20.04
MAINTAINER Colben colbenlee@gmail.com
ADD --chown=root:root /ADD/localtime /etc/localtime
ENV LANG=en_US.UTF-8
ENV LANGUAGE=en_US
RUN echo "\n\
export HISTCONTROL=ignoredups:ignorespace\n\
export HISTSIZE=10000\n\
export HISTFILESIZE=20000\n\
export HISTTIMEFORMAT='[%d %R] '\n\
export 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\] '\n\
export PS2='\[\e[36m\]>\[\e[0m\] '\n\
alias ls='ls --color=auto'\n\
alias grep='grep --color=auto'\n\
" > /etc/bash.bashrc \
&& ln -sf /bin/bash /bin/sh \
&& apt update -y \
&& apt install -y ca-certificates \
&& sed -i '/^deb /s,http://ports.ubuntu.com,https://mirrors.tuna.tsinghua.edu.cn,' /etc/apt/sources.list \
&& apt update -y \
&& apt install -y vim-tiny less curl iproute2 \
&& rm -rf /var/lib/apt/lists/* /var/lib/dpkg/info/* /var/cache/apt/archives /root/.bashrc /root/.profile

10
ubuntu/README.md Normal file
View File

@@ -0,0 +1,10 @@
# 构建 ubuntu 镜像
## 导入文件
- 本机时区 /etc/localtime
## 定制
- 使用 Asia/Shanghai 时区
- 安装 ca-certificates vim-tiny less curl iproute2
- 默认语言 en_US.UTF-8

69
ubuntu/ubuntu.sh Executable file
View File

@@ -0,0 +1,69 @@
#!/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:20"
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 {
Update
Build
END=1
}
# Start here
Main