Merge pull request #63 from DDS-Derek/main

frontend remote download
This commit is contained in:
jxxghp 2023-08-11 11:08:43 +08:00 committed by GitHub
commit 7d10bbd3ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 52 additions and 27 deletions

View File

@ -9,7 +9,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@master
uses: actions/checkout@v3
- name: Docker meta
id: meta
@ -24,49 +24,33 @@ jobs:
app_version=$(cat version.py |sed -ne "s/APP_VERSION\s=\s'v\(.*\)'/\1/gp")
echo "app_version=$app_version" >> $GITHUB_ENV
-
name: Setup node
uses: actions/setup-node@v3
with:
node-version: '18'
-
name: Build frontend
id: build_brontend
run: |
git clone https://github.com/jxxghp/MoviePilot-Frontend
cd MoviePilot-Frontend
yarn && yarn build
cd ..
mkdir -p public
cp -rf ./MoviePilot-Frontend/dist/* ./public/
rm -rf MoviePilot-Frontend
chmod +x start.sh
-
name: Set Up QEMU
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v2
-
name: Set Up Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2
-
name: Login DockerHub
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
-
name: Build Image
uses: docker/build-push-action@v2
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
file: Dockerfile
platforms: |
linux/amd64
linux/arm64
push: true
build-args: |
MOVIEPILOT_FRONTEND_VERSION=${{ env.app_version }}
tags: |
${{ secrets.DOCKER_USERNAME }}/moviepilot:latest
${{ secrets.DOCKER_USERNAME }}/moviepilot:${{ env.app_version }}

View File

@ -1,4 +1,5 @@
FROM python:3.10.11-slim
ARG MOVIEPILOT_FRONTEND_VERSION
ENV LANG="C.UTF-8" \
HOME="/moviepilot" \
TERM="xterm" \
@ -6,6 +7,7 @@ ENV LANG="C.UTF-8" \
PUID=0 \
PGID=0 \
UMASK=000 \
MOVIEPILOT_AUTO_UPDATE=true \
NGINX_PORT=3000 \
CONFIG_DIR="/config" \
API_TOKEN="moviepilot" \
@ -41,9 +43,12 @@ RUN apt-get update \
gosu \
bash \
wget \
&& mkdir -p /etc/nginx ${HOME} \
curl \
busybox \
&& cp -f nginx.conf /etc/nginx/nginx.template.conf \
&& mv ./public / \
&& cp update /usr/local/bin/mp_update \
&& chmod +x /usr/local/bin/mp_update \
&& mkdir -p ${HOME} \
&& groupadd -r moviepilot -g 911 \
&& useradd -r moviepilot -g moviepilot -d ${HOME} -s /bin/bash -u 911 \
&& pip install --upgrade pip \
@ -54,6 +59,8 @@ RUN apt-get update \
&& echo 'fs.inotify.max_user_watches=5242880' >> /etc/sysctl.conf \
&& echo 'fs.inotify.max_user_instances=5242880' >> /etc/sysctl.conf \
&& locale-gen zh_CN.UTF-8 \
&& curl -sL "https://github.com/jxxghp/MoviePilot-Frontend/releases/download/v${MOVIEPILOT_FRONTEND_VERSION}/dist.zip" | busybox unzip -d / - \
&& mv /dist /public \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf \

View File

@ -2,6 +2,12 @@
# 使用 `envsubst` 将模板文件中的 ${NGINX_PORT} 替换为实际的环境变量值
envsubst '${NGINX_PORT}' < /etc/nginx/nginx.template.conf > /etc/nginx/nginx.conf
# 自动更新
if [ "${MOVIEPILOT_AUTO_UPDATE}" = "true" ]; then
mp_update
else
echo "程序自动升级已关闭如需自动升级请在创建容器时设置环境变量MOVIEPILOT_AUTO_UPDATE=true"
fi
# 更改 moviepilot userid 和 groupid
groupmod -o -g ${PGID} moviepilot
usermod -o -u ${PUID} moviepilot

28
update Normal file
View File

@ -0,0 +1,28 @@
#!/bin/bash
old_version=$(cat /app/version.py)
new_version=$(curl -sL https://raw.githubusercontent.com/jxxghp/MoviePilot/main/version.py)
release_version=v$(echo ${new_version} | sed -ne "s/APP_VERSION\s=\s'v\(.*\)'/\1/gp")
if [ "${old_version}" != "${new_version}" ]; then
echo "发现新版本,开始更新程序..."
curl -sL "https://github.com/jxxghp/MoviePilot/archive/refs/tags/${release_version}.zip" | busybox unzip -d /tmp -
if [ $? -eq 0 ]; then
echo "后端下载成功"
curl -sL "https://github.com/jxxghp/MoviePilot-Frontend/releases/download/${release_version}/dist.zip" | busybox unzip -d /tmp -
if [ $? -eq 0 ]; then
echo "前端下载成功"
rm -rf /app
mv /tmp/MoviePilot* /app
rm -rf /public
mv /tmp/dist /public
echo "程序更新成功"
else
echo "前端下载失败,继续使用旧的程序来启动..."
fi
else
echo "后端下载失败,继续使用旧的程序来启动..."
fi
else
echo "未发现新版本,跳过更新步骤"
fi