优化 Dokcerfile、规范 WORKDIR 方便挂载本体

This commit is contained in:
stapxs 2024-04-18 10:50:46 +08:00
parent 3509533dd0
commit 0aaa08d3f4
No known key found for this signature in database
GPG Key ID: E2445576B8471A27
2 changed files with 18 additions and 20 deletions

View File

@ -1,29 +1,26 @@
FROM mlikiowa/napcat-docker:base
COPY NapCat.linux.zip /tmp/NapCat.linux.zip
COPY config.txt entrypoint.sh /root/
WORKDIR /usr/src/app
COPY NapCat.linux.zip NapCat.linux.zip
COPY config.txt entrypoint.sh ./
# 安装Linux QQ
RUN arch=$(arch | sed s/aarch64/arm64/ | sed s/x86_64/amd64/) && \
curl -o /root/linuxqq.deb https://dldir1.qq.com/qqfile/qq/QQNT/Linux/QQ_3.2.7_240410_${arch}_01.deb && \
ls -lh /root && \
dpkg -i --force-depends /root/linuxqq.deb && rm /root/linuxqq.deb && \
dpkg -i --force-depends /root/linuxqq.deb && rm /root/linuxqq.deb
# 安装 napcat
unzip /tmp/NapCat.linux.zip -d /root/ && \
mv /root/NapCat.linux.$(arch | sed s/aarch64/arm64/ | sed s/x86_64/x64/)/* /root/ && \
rm /tmp/NapCat.linux.zip && \
ln -s /usr/bin/ffmpeg /root/ffmpeg && \
# 安装 napcat
RUN unzip NapCat.linux.zip && \
rm NapCat.linux.zip && \
chmod +x napcat.sh && \
chmod +x entrypoint.sh
chmod +x /root/napcat.sh && \
chmod +x /root/entrypoint.sh && \
echo "[supervisord]" > /etc/supervisord.conf && \
# 配置 supervisord
RUN 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"]
ENTRYPOINT ["sh", "entrypoint.sh"]

View File

@ -1,11 +1,11 @@
#!/bin/bash
sed -i "s|COMMAND|bash /root/napcat.sh -q $ACCOUNT|" /etc/supervisord.conf
sed -i "s|COMMAND|bash napcat.sh -q $ACCOUNT|" /etc/supervisord.conf
CONFIG_PATH=/root/config/onebot11_$ACCOUNT.json
CONFIG_PATH=config/onebot11_$ACCOUNT.json
# 容器首次启动时执行
if [ ! -f "$CONFIG_PATH" ]; then
cp -f /root/config.txt $CONFIG_PATH
cp -f config.txt $CONFIG_PATH
if [ "$HTTP_PORT" ]; then
@ -93,5 +93,6 @@ if [ ! -f "$CONFIG_PATH" ]; then
fi
fi
bash /root/napcat.sh -q $ACCOUNT &
export FFMPEG_PATH=/usr/bin/ffmpeg
bash napcat.sh -q $ACCOUNT &
exec supervisord