完成docker模块

This commit is contained in:
lsy 2024-07-24 18:41:04 +08:00
parent 7aa7f119f4
commit b73e72c2e9
8 changed files with 294 additions and 5 deletions

View File

@ -14,8 +14,7 @@ services:
ports:
- "${port}:5244"
EOF
sudo docker compose up -d | "安装失败" $$ exit
declare password=$( docker exec -it alist ./alist admin random )
sudo docker compose up -d || "安装失败" $$ exit
declare password=$( sudo docker exec -it alist ./alist admin random | grep password | awk '{print $4}')
echo "账号admin"
echo "密码:${password}"
cd - >> /dev/null

View File

@ -0,0 +1,58 @@
#!/bin/bash
declare path=$1
declare port=$2
sudo useradd -m git
sudo -u git ssh-keygen -t rsa -b 4096 -C "Gitea Host Key" -f /home/git/.ssh/id_rsa -N ""
sudo -u git sh -c 'cat /home/git/.ssh/id_rsa.pub >> /home/git/.ssh/authorized_keys'
declare uid=$( id git | awk -F'[=() ]+' '{print $2}' )
declare gid=$( id git | awk -F'[=() ]+' '{print $5}' )
cd $path
cat > "docker-compose.yml" << EOF
networks:
gitea:
external: false
services:
server:
image: gitea/gitea:latest
container_name: gitea
environment:
- USER_UID=${uid}
- USER_GID=${gid}
- GITEA__database__DB_TYPE=mysql
- GITEA__database__HOST=db:3306
- GITEA__database__NAME=gitea
- GITEA__database__USER=gitea
- GITEA__database__PASSWD=gitea
restart: always
networks:
- gitea
volumes:
- ./data:/data
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
- /home/git/.ssh/:/data/git/.ssh
ports:
- "${port}:3000"
- "$(( port+22 )):22"
depends_on:
- db
db:
image: mysql:8
restart: always
environment:
- MYSQL_ROOT_PASSWORD=gitea
- MYSQL_USER=gitea
- MYSQL_PASSWORD=gitea
- MYSQL_DATABASE=gitea
networks:
- gitea
volumes:
- ./mysql:/var/lib/mysql
EOF
sudo docker compose up -d
sudo -u git ssh -p $(( port+22 )) -o StrictHostKeyChecking=no git@127.0.0.1 "SSH_ORIGINAL_COMMAND=\"$SSH_ORIGINAL_COMMAND\" $0 $@"

View File

@ -0,0 +1,21 @@
#!/bin/bash
declare path=$1
declare port=$2
cd $path
cat > docker-compose.yml << EOF
services:
app:
image: 'jc21/nginx-proxy-manager:latest'
restart: unless-stopped
ports:
- '80:80'
- '443:443'
- '${port}:81'
volumes:
- ./data:/data
- ./letsencrypt:/etc/letsencrypt
EOF
sudo docker compose up -d
echo "Email: admin@example.com"
echo "Password: changeme"

View File

@ -0,0 +1,18 @@
#!/bin/bash
declare path=$1
declare port=$2
cd $path
wget "https://waf-ce.chaitin.cn/release/latest/compose.yaml"
cat > ".env" << EOF
SAFELINE_DIR=$path
IMAGE_TAG=latest
MGT_PORT=$port
POSTGRES_PASSWORD="safeline"
SUBNET_PREFIX=172.22.222
IMAGE_PREFIX=chaitin
EOF
sudo docker compose up -d || "安装失败" $$ exit
declare password=$( docker exec safeline-mgt resetadmin | grep password | awk -F "" '{print $2}' )
echo "账号admin"
echo "密码:${password}"

View File

@ -0,0 +1,31 @@
#!/bin/bash
declare path=$1
declare port=$2
declare password
read -p "请输入思源访问密码,(默认 Siyuan )" password
if [[ -z $password ]];then
password="Siyuan"
fi
sudo chown -R 1000:1000 $path
cd $path
cat > "docker-compose.yml" << EOF
version: "3.9"
services:
siyuan:
image: b3log/siyuan
container_name: siyuan
user: '1000:1000'
restart: always
ports:
- $port:6806
volumes:
- ./:/siyuan/workspace
command:
- "--workspace=/siyuan/workspace/"
- "--lang=zh_CN"
- "--accessAuthCode=$password"
EOF
sudo docker compose up -d || "安装失败" $$ exit
echo "访问密码:$password"

View File

@ -0,0 +1,119 @@
#!/bin/bash
declare path=$1
declare port=$2
cd $path
mkdir data
mkdir php
mkdir -p nginx/conf
cat > "./php/Dockerfile" << 'EOF'
FROM php:fpm
# 更新包列表并安装 pdo_mysql 扩展
RUN apt-get update && \
apt-get install -y libpq-dev && \
docker-php-ext-install pdo_mysql && \
rm -rf /var/lib/apt/lists/*
# 设置 PHP 配置
RUN { \
echo "output_buffering = 4096"; \
echo "date.timezone = PRC"; \
} > /usr/local/etc/php/conf.d/custom.ini
EOF
cat > "./nginx/conf/default.conf" << 'EOF'
server {
listen 80 default_server; # 监听 80 端口
root /var/www/html; # 网站根目录
index index.php index.html index.htm;
access_log /var/log/nginx/typecho_access.log main; # 访问日志
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php$1 last; # 重写 URL 到 index.php
}
location / {
if (!-e $request_filename) {
rewrite . /index.php last; # 如果文件不存在,重写到 index.php
}
}
location ~ \.php(.*)$ {
fastcgi_pass php:9000; # 转发 PHP 请求到 php-fpm 服务
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # 设置脚本文件名参数
include fastcgi_params; # 包含 fastcgi 参数
}
}
EOF
cat > docker-compose.yml << EOF
services: # 定义多个服务
nginx: # 服务名称
image: nginx # 使用的镜像
ports: # 映射的端口
- "${port}:80" # 宿主机端口 ${port} 映射到容器端口 80
restart: always # 容器重启策略
volumes: # 映射文件
- ./data:/var/www/html # 网站源代码
- ./nginx/conf:/etc/nginx/conf.d # nginx 站点配置文件
- ./nginx/logs:/var/log/nginx # nginx 日志文件
depends_on: # 定义依赖关系
- php # 依赖 php 服务
networks: # 要加入的网络
- typecho # 加入 typecho 网络
php: # 服务名称
build: ./php # 构建文件的目录
restart: always # 容器重启策略
volumes: # 映射文件
- ./data:/var/www/html # 网站源代码
depends_on: # 定义依赖关系
- mysql # 依赖 mysql 服务
networks: # 要加入的网络
- typecho # 加入 typecho 网络
mysql: # 服务名称
image: mysql:5.7 # 指定 5.7 版本的 mysql 镜像
restart: always # 容器重启策略
volumes: # 要映射的文件
- ./mysql/data:/var/lib/mysql # mysql 数据
- ./mysql/logs:/var/log/mysql # mysql 日志
- ./mysql/conf:/etc/mysql/conf.d # mysql 配置文件
environment: # 环境变量
MYSQL_ROOT_PASSWORD: typecho # MySQL root 用户的密码
MYSQL_DATABASE: typecho # 创建的数据库名称
networks: # 要加入的网络
- typecho # 加入 typecho 网络
networks: # 定义的内部网络
typecho: # 网络名称
EOF
cd data
wget https://github.com/typecho/typecho/releases/download/v1.2.1/typecho.zip -O typecho.zip
unzip typecho.zip
rm typecho.zip
cd $path
sudo chown -R 1000:1000 $path
sudo chmod -R 777 data
sudo docker compose up -d
echo "数据库地址mysql"
echo "数据库用户名root"
echo "数据库密码typecho"
echo "数据库名typecho"
echo "安装完成在${path}/data/config.inc.php末尾加上,防止排版错误"
echo "define('__TYPECHO_SECURE__',true);"

View File

@ -0,0 +1,44 @@
#!/bin/bash
declare path=$1
declare port=$2
declare password
read -p "请输入管理员密码(不输入则关闭管理员)" password
cd $path
cat > "docker-compose.yml" << EOF
version: '3.8'
services:
bitwarden:
image: vaultwarden/server:latest
container_name: vaultwarden
restart: always
environment:
- SIGNUPS_ALLOWED=true
- WEBSOCKET_ENABLED=true
- TZ=Asia/Shanghai
- ADMIN_TOKEN="$password"
volumes:
- ./:/data/
ports:
- "${port}:80"
EOF
if [[ -z $password ]];then
awk '!/ADMIN_TOKEN=/' docker-compose.yml > tmpfile && mv tmpfile docker-compose.yml
fi
mkdir templates
cd templates
wget https://github.com/wcjxixi/vaultwarden-lang-zhcn/archive/refs/heads/main.zip
unzip main.zip
rm main.zip
cd vaultwarden-lang-zhcn-main
declare admin=$( ls | grep "admin" | tac | head -n 1 )
declare email=$( ls | grep "email" | tac | head -n 1 )
mv "$admin" admin && cp -r admin ..
mv "$email" email && cp -r email ..
cd ..
rm -rf vaultwarden-lang-zhcn-main
sudo docker compose up -d || echo "安装失败" && exiti
echo "需要反向代理,使用https,才能正常使用"

View File

@ -92,8 +92,7 @@ elif [[ "${pick}" -gt "$((${pick_number}-${#pick_array[*]}))" && "${pick}" -le "
fi
bash Config/Docker/${pick_array[${pick}]}.sh "$file_path" "$port"
echo "访问链接http://127.0.0.1:${port}"
echo "${pick_array[${pick}]}安装完成"
echo "${pick_array[${pick}]}安装完成,访问端口${port}"
fi