mirror of
https://github.com/NapNeko/NapCat-Docker.git
synced 2025-12-19 22:52:10 +08:00
initial commit
This commit is contained in:
parent
6fec8bbfe3
commit
70cb8c5092
109
.github/workflows/base-docker-publish.yml
vendored
Normal file
109
.github/workflows/base-docker-publish.yml
vendored
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
name: base
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY_IMAGE: mlikiowa/napcat-docker
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
platform:
|
||||||
|
- linux/amd64
|
||||||
|
- linux/arm64
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Prepare
|
||||||
|
run: |
|
||||||
|
platform=${{ matrix.platform }}
|
||||||
|
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
-
|
||||||
|
name: Docker meta
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: ${{ env.REGISTRY_IMAGE }}
|
||||||
|
tags: |
|
||||||
|
type=raw,value=base,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
|
||||||
|
-
|
||||||
|
name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
-
|
||||||
|
name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
-
|
||||||
|
name: Build and push by digest
|
||||||
|
id: build
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: ./base/.
|
||||||
|
platforms: ${{ matrix.platform }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
|
||||||
|
-
|
||||||
|
name: Export digest
|
||||||
|
run: |
|
||||||
|
mkdir -p /tmp/digests
|
||||||
|
digest="${{ steps.build.outputs.digest }}"
|
||||||
|
touch "/tmp/digests/${digest#sha256:}"
|
||||||
|
-
|
||||||
|
name: Upload digest
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: digests-${{ env.PLATFORM_PAIR }}
|
||||||
|
path: /tmp/digests/*
|
||||||
|
if-no-files-found: error
|
||||||
|
retention-days: 1
|
||||||
|
|
||||||
|
merge:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs:
|
||||||
|
- build
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Download digests
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
path: /tmp/digests
|
||||||
|
pattern: digests-*
|
||||||
|
merge-multiple: true
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
-
|
||||||
|
name: Docker meta
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: ${{ env.REGISTRY_IMAGE }}
|
||||||
|
tags: |
|
||||||
|
type=raw,value=base,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
|
||||||
|
-
|
||||||
|
name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
-
|
||||||
|
name: Create manifest list and push
|
||||||
|
working-directory: /tmp/digests
|
||||||
|
run: |
|
||||||
|
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
|
||||||
|
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
|
||||||
|
-
|
||||||
|
name: Inspect image
|
||||||
|
run: |
|
||||||
|
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
|
||||||
112
.github/workflows/docker-publish.yml
vendored
Normal file
112
.github/workflows/docker-publish.yml
vendored
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
name: ci
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
# push:
|
||||||
|
# branches:
|
||||||
|
# - "main"
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY_IMAGE: mlikiowa/napcat-docker
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
platform:
|
||||||
|
- linux/amd64
|
||||||
|
- linux/arm64
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Prepare
|
||||||
|
run: |
|
||||||
|
platform=${{ matrix.platform }}
|
||||||
|
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
-
|
||||||
|
name: Docker meta
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: ${{ env.REGISTRY_IMAGE }}
|
||||||
|
tags: |
|
||||||
|
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
|
||||||
|
-
|
||||||
|
name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
-
|
||||||
|
name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
-
|
||||||
|
name: Build and push by digest
|
||||||
|
id: build
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
platforms: ${{ matrix.platform }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
|
||||||
|
-
|
||||||
|
name: Export digest
|
||||||
|
run: |
|
||||||
|
mkdir -p /tmp/digests
|
||||||
|
digest="${{ steps.build.outputs.digest }}"
|
||||||
|
touch "/tmp/digests/${digest#sha256:}"
|
||||||
|
-
|
||||||
|
name: Upload digest
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: digests-${{ env.PLATFORM_PAIR }}
|
||||||
|
path: /tmp/digests/*
|
||||||
|
if-no-files-found: error
|
||||||
|
retention-days: 1
|
||||||
|
|
||||||
|
merge:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs:
|
||||||
|
- build
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Download digests
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
path: /tmp/digests
|
||||||
|
pattern: digests-*
|
||||||
|
merge-multiple: true
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
-
|
||||||
|
name: Docker meta
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: ${{ env.REGISTRY_IMAGE }}
|
||||||
|
tags: |
|
||||||
|
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
|
||||||
|
-
|
||||||
|
name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
-
|
||||||
|
name: Create manifest list and push
|
||||||
|
working-directory: /tmp/digests
|
||||||
|
run: |
|
||||||
|
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
|
||||||
|
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
|
||||||
|
-
|
||||||
|
name: Inspect image
|
||||||
|
run: |
|
||||||
|
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
|
||||||
46
Dockerfile
46
Dockerfile
@ -1,25 +1,25 @@
|
|||||||
FROM ubuntu:22.04
|
FROM initialencounter/napcat:base
|
||||||
|
|
||||||
ENV DEBIAN_FRONTEND=noninteractive
|
COPY NapCat.linux.x64.zip /tmp/NapCat.linux.x64.zip
|
||||||
ENV VNC_PASSWD=vncpasswd
|
COPY config.txt entrypoint.sh /root/
|
||||||
|
|
||||||
|
# 安装Linux QQ
|
||||||
|
RUN curl -o /root/linuxqq.deb https://dldir1.qq.com/qqfile/qq/QQNT/Linux/QQ_3.2.7_240410_amd64_01.deb && \
|
||||||
|
dpkg -i --force-depends /root/linuxqq.deb && rm /root/linuxqq.deb && \
|
||||||
|
|
||||||
|
# 安装 napcat
|
||||||
|
unzip /tmp/NapCat.linux.x64.zip -d /root/ && \
|
||||||
|
rm /tmp/NapCat.linux.x64.zip && \
|
||||||
|
|
||||||
|
chmod +x /root/napcat.sh && \
|
||||||
|
chmod +x /root/entrypoint.sh && \
|
||||||
|
|
||||||
|
echo "[supervisord]" > /etc/supervisord.conf && \
|
||||||
|
echo "nodaemon=true" >> /etc/supervisord.conf && \
|
||||||
|
echo "[program:napcat]" >> /etc/supervisord.conf && \
|
||||||
|
echo "command=COMMAND" >> /etc/supervisord.conf
|
||||||
|
|
||||||
|
WORKDIR "/root"
|
||||||
|
|
||||||
|
ENTRYPOINT ["/root/entrypoint.sh"]
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y \
|
|
||||||
openbox \
|
|
||||||
xorg \
|
|
||||||
dbus-user-session \
|
|
||||||
curl \
|
|
||||||
unzip \
|
|
||||||
xvfb \
|
|
||||||
supervisor \
|
|
||||||
libnotify4 \
|
|
||||||
libnss3 \
|
|
||||||
xdg-utils \
|
|
||||||
libsecret-1-0 \
|
|
||||||
ffmpeg \
|
|
||||||
libgbm1 \
|
|
||||||
libasound2 \
|
|
||||||
fonts-wqy-zenhei \
|
|
||||||
git \
|
|
||||||
gnutls-bin && \
|
|
||||||
apt-get clean --no-install-recommends && \
|
|
||||||
rm -rf /var/lib/apt/lists/* && \
|
|
||||||
|
|||||||
35
README.md
35
README.md
@ -1,2 +1,37 @@
|
|||||||
# NapCat-Docker
|
# NapCat-Docker
|
||||||
NapCat-Docker
|
NapCat-Docker
|
||||||
|
|
||||||
|
|
||||||
|
## 正向 WS
|
||||||
|
|
||||||
|
```shell
|
||||||
|
docker run \
|
||||||
|
-e ACCOUNT=<机器人qq> \
|
||||||
|
-d -p 3001:3001 \
|
||||||
|
-e WS_ENABLE=true \
|
||||||
|
--name napcat \
|
||||||
|
mlikiowa/napcat-docker:latest
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## 反向 WS
|
||||||
|
|
||||||
|
```shell
|
||||||
|
docker run -d \
|
||||||
|
-e ACCOUNT=<机器人qq> \
|
||||||
|
-e WSR_ENABLE=true \
|
||||||
|
-e WS_URLS="http://localhost:5140/onebot"
|
||||||
|
--name napcat \
|
||||||
|
mlikiowa/napcat-docker:latest
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## HTTP
|
||||||
|
```shell
|
||||||
|
docker run \
|
||||||
|
-e ACCOUNT=<机器人qq> \
|
||||||
|
-d -p 3000:3000 \
|
||||||
|
-e HTTP_ENABLE=true \
|
||||||
|
--name napcat \
|
||||||
|
mlikiowa/napcat-docker:latest
|
||||||
|
```
|
||||||
30
base/Dockerfile
Normal file
30
base/Dockerfile
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
FROM ubuntu:22.04
|
||||||
|
|
||||||
|
# 设置环境变量
|
||||||
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
|
# 安装必要的软件包
|
||||||
|
RUN apt-get update && apt-get install -y \
|
||||||
|
libnss3 \
|
||||||
|
libnotify4 \
|
||||||
|
libsecret-1-0 \
|
||||||
|
libgbm1 \
|
||||||
|
libasound2 \
|
||||||
|
fonts-wqy-zenhei \
|
||||||
|
gnutls-bin \
|
||||||
|
libglib2.0-dev \
|
||||||
|
libdbus-1-3 \
|
||||||
|
libgtk-3-0 \
|
||||||
|
libxss1 \
|
||||||
|
libxtst6 \
|
||||||
|
libatspi2.0-0 \
|
||||||
|
libx11-xcb1 \
|
||||||
|
unzip \
|
||||||
|
curl \
|
||||||
|
supervisor && \
|
||||||
|
apt autoremove -y && \
|
||||||
|
apt clean && \
|
||||||
|
rm -rf \
|
||||||
|
/var/lib/apt/lists/* \
|
||||||
|
/tmp/* \
|
||||||
|
/var/tmp/*
|
||||||
17
config.txt
Normal file
17
config.txt
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"httpPort": HTTP_PORT,
|
||||||
|
"httpPostUrls": ["HTTP_URLS"],
|
||||||
|
"httpSecret": "",
|
||||||
|
"wsPort": WS_PORT,
|
||||||
|
"wsReverseUrls": ["WS_URLS"],
|
||||||
|
"enableHttp": HTTP_ENABLE,
|
||||||
|
"enableHttpPost": HTTP_POST_ENABLE,
|
||||||
|
"enableWs": WS_ENABLE,
|
||||||
|
"enableWsReverse": WSR_ENABLE,
|
||||||
|
"messagePostFormat": "array",
|
||||||
|
"reportSelfMessage": RSM_ENABLE,
|
||||||
|
"debug": DEBUG_ENABLE,
|
||||||
|
"enableLocalFile2Url": F2U_ENABLE,
|
||||||
|
"heartInterval": HEART,
|
||||||
|
"token": "TOKEN"
|
||||||
|
}
|
||||||
97
entrypoint.sh
Normal file
97
entrypoint.sh
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
sed -i "s|COMMAND|bash /root/napcat.sh -q $ACCOUNT|" /etc/supervisord.conf
|
||||||
|
|
||||||
|
CONFIG_PATH=/root/config/onebot11_$ACCOUNT.json
|
||||||
|
# 容器首次启动时执行
|
||||||
|
if [ ! -f "$CONFIG_PATH" ]; then
|
||||||
|
cp -f /root/config.txt $CONFIG_PATH
|
||||||
|
|
||||||
|
|
||||||
|
if [ "$HTTP_PORT" ]; then
|
||||||
|
sed -i "s/HTTP_PORT/$HTTP_PORT/" $CONFIG_PATH
|
||||||
|
else
|
||||||
|
sed -i "s/HTTP_PORT/3000/" $CONFIG_PATH
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$HTTP_URLS" ]; then
|
||||||
|
sed -i "s|HTTP_URLS|$HTTP_URLS|" $CONFIG_PATH
|
||||||
|
else
|
||||||
|
sed -i "s/\"HTTP_URLS\"/\"\"/" $CONFIG_PATH
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$WS_PORT" ]; then
|
||||||
|
sed -i "s/WS_PORT/$WS_PORT/" $CONFIG_PATH
|
||||||
|
else
|
||||||
|
sed -i "s/WS_PORT/3001/" $CONFIG_PATH
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$HTTP_ENABLE" ]; then
|
||||||
|
sed -i "s/HTTP_ENABLE/$HTTP_ENABLE/" $CONFIG_PATH
|
||||||
|
else
|
||||||
|
sed -i "s/HTTP_ENABLE/false/" $CONFIG_PATH
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$HTTP_POST_ENABLE" ]; then
|
||||||
|
sed -i "s/HTTP_POST_ENABLE/$HTTP_POST_ENABLE/" $CONFIG_PATH
|
||||||
|
else
|
||||||
|
sed -i "s/HTTP_POST_ENABLE/false/" $CONFIG_PATH
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$WS_ENABLE" ]; then
|
||||||
|
sed -i "s/WS_ENABLE/$WS_ENABLE/" $CONFIG_PATH
|
||||||
|
else
|
||||||
|
sed -i "s/WS_ENABLE/false/" $CONFIG_PATH
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$WSR_ENABLE" ]; then
|
||||||
|
sed -i "s/WSR_ENABLE/$WSR_ENABLE/" $CONFIG_PATH
|
||||||
|
else
|
||||||
|
sed -i "s/WSR_ENABLE/false/" $CONFIG_PATH
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "WS_URLS" ]; then
|
||||||
|
sed -i "s/WS_URLS/$WS_URLS/" $CONFIG_PATH
|
||||||
|
else
|
||||||
|
sed -i "s/\"WS_URLS\"/\"\"/" $CONFIG_PATH
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$HEART" ]; then
|
||||||
|
sed -i "s/HEART/$HEART/" $CONFIG_PATH
|
||||||
|
else
|
||||||
|
sed -i "s/HEART/60000/" $CONFIG_PATH
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$TOKEN" ]; then
|
||||||
|
sed -i "s|TOKEN|$TOKEN|" $CONFIG_PATH
|
||||||
|
else
|
||||||
|
sed -i "s/\"TOKEN\"/\"\"/" $CONFIG_PATH
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$F2U_ENABLE" ]; then
|
||||||
|
sed -i "s/F2U_ENABLE/$F2U_ENABLE/" $CONFIG_PATH
|
||||||
|
else
|
||||||
|
sed -i "s/F2U_ENABLE/false/" $CONFIG_PATH
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$DEBUG_ENABLE" ]; then
|
||||||
|
sed -i "s/DEBUG_ENABLE/$DEBUG_ENABLE/" $CONFIG_PATH
|
||||||
|
else
|
||||||
|
sed -i "s/DEBUG_ENABLE/false/" $CONFIG_PATH
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$LOG_ENABLE" ]; then
|
||||||
|
sed -i "s/LOG_ENABLE/$LOG_ENABLE/" $CONFIG_PATH
|
||||||
|
else
|
||||||
|
sed -i "s/LOG_ENABLE/false/" $CONFIG_PATH
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$RSM_ENABLE" ]; then
|
||||||
|
sed -i "s/RSM_ENABLE/$RSM_ENABLE/" $CONFIG_PATH
|
||||||
|
else
|
||||||
|
sed -i "s/RSM_ENABLE/false/" $CONFIG_PATH
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
bash /root/napcat.sh -q $ACCOUNT &
|
||||||
|
exec supervisord
|
||||||
18
get_artifacts.sh
Normal file
18
get_artifacts.sh
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# 设置仓库信息
|
||||||
|
repository="NapNeko/NapCat.Build"
|
||||||
|
run_id="8662095740"
|
||||||
|
artifact_name="NapCat.linux.x64"
|
||||||
|
token=""
|
||||||
|
|
||||||
|
# 设置输出目录
|
||||||
|
output_dir="."
|
||||||
|
|
||||||
|
# 获取artifact ID
|
||||||
|
artifact_id=$(curl -s -X GET -H "Authorization: token $token" "https://api.github.com/repos/$repository/actions/runs/$run_id/artifacts" | jq -r ".artifacts[] | select(.name == \"$artifact_name\") | .id")
|
||||||
|
|
||||||
|
# 下载artifact
|
||||||
|
curl -s -X GET -H "Authorization: token $token" -L "https://api.github.com/repos/$repository/actions/artifacts/$artifact_id/zip" -o "$output_dir/$artifact_name.zip"
|
||||||
|
|
||||||
|
echo "编译产物已保存到$output_dir/$artifact_name.zip"
|
||||||
Loading…
Reference in New Issue
Block a user