This commit is contained in:
chenc 2023-11-27 17:17:47 +08:00
parent 6d44f4b40e
commit 6d0e9dd4ac
3 changed files with 77 additions and 5 deletions

12
.alias Normal file
View File

@ -0,0 +1,12 @@
alias aix-docker='docker-compose -f $AIX_DOCKER_COMPOSER_FILE'
alias aix-docker-up='docker-compose -f $AIX_DOCKER_COMPOSER_FILE up --build -d'
alias aix-docker-down='docker-compose -f $AIX_DOCKER_COMPOSER_FILE down'
alias aix-docker-restart='docker-compose -f $AIX_DOCKER_COMPOSER_FILE restart'
alias aix-php73-base='docker-compose -f $AIX_DOCKER_COMPOSER_FILE exec php73 /bin/sh'
alias aix-php74-base='docker-compose -f $AIX_DOCKER_COMPOSER_FILE exec php74 /bin/sh'
alias aix-php81-base='docker-compose -f $AIX_DOCKER_COMPOSER_FILE exec php81 /bin/sh'
alias aix-redis-base='docker-compose -f $AIX_DOCKER_COMPOSER_FILE exec redis /bin/sh'
alias aix-nginx-base='docker-compose -f $AIX_DOCKER_COMPOSER_FILE exec openresty /bin/sh'
alias aix-elastic-base='docker-compose -f $AIX_DOCKER_COMPOSER_FILE exec elasticsearch /bin/sh'
alias aix-php81-supervisor='docker-compose -f $AIX_DOCKER_COMPOSER_FILE exec php81 supervisorctl'
alias aix-php73-supervisor='docker-compose -f $AIX_DOCKER_COMPOSER_FILE exec php81 supervisorctl'

View File

@ -121,6 +121,11 @@ lua_shared_dict my_limit_req_store1 100m;
return 200 'alive' ;
}
}
server {
listen 443;
server_name _;
return 444;
}
########################## vhost #############################
include vhost/*.conf;
}

View File

@ -1,9 +1,37 @@
#/bin/sh
docker_path="/data/aix-docker"
pushd /data
function print_error() {
RED='\033[0;31m'
NC='\033[0m'
echo -e "${RED}[ERROR] $1${NC}" >&2
}
function print_success() {
GREEN='\033[0;32m'
NC='\033[0m'
echo -e "${GREEN}[SUCCESS] $1${NC}" >&2
}
if [ "$EUID" -ne 0 ]; then
print_error "Please running as root"
fi
if [ -e "/root/.aix_docker.lock" ]; then
print_error "Initialization has been performed!"
exit 1
fi
if ! command -v jq >/dev/null 2>&1 ; then
if [ -f /etc/redhat-release ]; then
yum install -y jq
elif [ -f /etc/debian_version ]; then
apt-get install -y jq
else
print_error "Unsupported Linux distribution"
exit 1
fi
if ! command -v docker >/dev/null 2>&1 ; then
wget --no-check-certificate https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/static/stable/x86_64/docker-20.10.9.tgz
if [ $? -ne 0 ]; then
echo "Download docker failed"
print_error "Download docker failed"
exit 1
fi
tar -zxvf docker-20.10.9.tgz
@ -42,11 +70,38 @@ if ! command -v docker-compose >/dev/null 2>&1 ; then
fi
if ! command -v git > /dev/null 2>&1 ; then
echo '请安装Git'
print_error '请安装Git'
return 1;
fi
git clone https://opencode.jsaix.cn/chenc/aix-docker.git /data/aix-docker
cd /data/aix-docker
docker-compose up --build -d
if [ ! -d "$docker_path" ]; then
git clone https://opencode.jsaix.cn/chenc/aix-docker.git /data/aix-docker
if [ $? -ne 0 ]; then
print_error "git clone aix-docker failed"
exit 1
fi
fi
pushd /data/aix-docker
yaml_file=$(find "$(pwd)" -type f -name "*.yaml" -o -name "*.yml" | head -n 1)
if [ -n "$yaml_file" ]; then
if [ -z "$AIX_DOCKER_COMPOSER_FILE" ]; then
echo 'export AIX_DOCKER_COMPOSER_FILE=$yaml_file' >> ~/.bashrc
source ~/.bashrc
print_success "AIX_DOCKER_COMPOSER_FILE environment variable set to '$yaml_file'"
else
echo "AIX_DOCKER_COMPOSER_FILE is already set to: $AIX_DOCKER_COMPOSER_FILE"
fi
else
print_error "Please config docker composer startup yaml file"
exit 1
fi
if grep -q "/data/aix-docker/.alias" ~/.bashrc; then
print_success ".alias is already sourced in ~/.bashrc"
else
echo "source /data/aix-docker/.alias" >> ~/.bashrc
source ~/.bashrc
fi
touch /root/.aix_docker.lock
print_success "script init success!"