Skip to content

Commit

Permalink
fix: 重启更新
Browse files Browse the repository at this point in the history
  • Loading branch information
DDSRem committed Sep 8, 2023
1 parent 55dce26 commit c8bc6a4
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 17 deletions.
22 changes: 12 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ secrets.DOCKER_USERNAME }}/moviepilot
uses: actions/checkout@v4

-
name: Release version
Expand All @@ -29,6 +23,16 @@ jobs:
app_version=$(cat version.py |sed -ne "s/APP_VERSION\s=\s'v\(.*\)'/\1/gp")
echo "app_version=$app_version" >> $GITHUB_ENV
-
name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ secrets.DOCKER_USERNAME }}/moviepilot
tags: |
type=raw,value=${{ env.app_version }}
type=raw,value=latest
-
name: Set Up QEMU
uses: docker/setup-qemu-action@v2
Expand All @@ -55,7 +59,5 @@ jobs:
push: true
build-args: |
MOVIEPILOT_VERSION=${{ env.app_version }}
tags: |
${{ secrets.DOCKER_USERNAME }}/moviepilot:latest
${{ secrets.DOCKER_USERNAME }}/moviepilot:${{ env.app_version }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

-
name: Release Version
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ RUN apt-get update \
&& cp -f /app/update /usr/local/bin/mp_update \
&& cp -f /app/entrypoint /entrypoint \
&& chmod +x /entrypoint /usr/local/bin/mp_update \
&& mkdir -p ${HOME} \
&& mkdir -p ${HOME} /var/lib/haproxy/server-state \
&& groupadd -r moviepilot -g 911 \
&& useradd -r moviepilot -g moviepilot -d ${HOME} -s /bin/bash -u 911 \
&& apt-get install -y build-essential \
Expand Down
4 changes: 2 additions & 2 deletions entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ gosu moviepilot:moviepilot playwright install chromium
# 启动前端nginx服务
nginx
# 启动haproxy
if [ -f "/var/run/docker.sock" ]; then
haproxy -f /etc/haproxy/haproxy.cfg
if [ -S "/var/run/docker.sock" ]; then
haproxy -f /app/haproxy.cfg
fi
# 设置后端服务权限掩码
umask ${UMASK}
Expand Down
14 changes: 11 additions & 3 deletions haproxy.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ global
# Turn on stats unix socket
server-state-file /var/lib/haproxy/server-state

setenv POST 1
setenv ALLOW_RESTARTS 1
setenv CONTAINERS 1
setenv VERSION 1

defaults
mode http
log global
Expand Down Expand Up @@ -46,7 +51,10 @@ backend dockerbackend

frontend dockerfrontend
bind :2375
http-request allow
http-request allow if { path,url_dec -m reg -i ^(/v[\d\.]+)?/containers/[a-zA-Z0-9_.-]+/((stop)|(restart)|(kill)) }
http-request deny unless METH_GET || { env(POST) -m bool }
http-request allow if { path,url_dec -m reg -i ^(/v[\d\.]+)?/containers/[a-zA-Z0-9_.-]+/((stop)|(restart)|(kill)) } { env(ALLOW_RESTARTS) -m bool }
http-request allow if { path,url_dec -m reg -i ^(/v[\d\.]+)?/containers } { env(CONTAINERS) -m bool }
http-request allow if { path,url_dec -m reg -i ^(/v[\d\.]+)?/version } { env(VERSION) -m bool }
http-request deny
default_backend dockerbackend
default_backend dockerbackend

0 comments on commit c8bc6a4

Please sign in to comment.