一分钟搭建影视站,支持Docker等部署方式
test
developerad4341d9260e
diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.ymlindex 19bef60..4083f4a 100644--- a/.github/workflows/docker-build.yml+++ b/.github/workflows/docker-build.yml@@ -40,4 +40,4 @@ jobs:file: Dockerfilepush: truetags: "${{ env.DOCKER_USERNAME }}/libretv:latest"- platforms: linux/amd64,linux/arm64/v8,linux/arm/v7,linux/arm/v6,linux/386,linux/s390x\ No newline at end of file+ platforms: linux/amd64,linux/arm64/v8\ No newline at end of filediff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.ymldeleted file mode 100644index 8ffe3c5..0000000--- a/.github/workflows/docker-publish.yml+++ /dev/null@@ -1,52 +0,0 @@-name: Docker Build and Push--on:- push:- branches: [ main, master ]- tags: [ 'v*' ]- pull_request:- branches: [ main, master ]--jobs:- build:- runs-on: ubuntu-latest- steps:- - name: Checkout repository- uses: actions/checkout@v3-- - name: Set up QEMU- uses: docker/setup-qemu-action@v2-- - name: Set up Docker Buildx- uses: docker/setup-buildx-action@v2-- - name: Login to DockerHub- if: github.event_name != 'pull_request'- uses: docker/login-action@v2- with:- username: ${{ secrets.DOCKERHUB_USERNAME }}- password: ${{ secrets.DOCKERHUB_TOKEN }}-- - name: Extract metadata for Docker- id: meta- uses: docker/metadata-action@v4- with:- images: bestzwei/libretv- tags: |- type=ref,event=branch- type=ref,event=pr- type=semver,pattern={{version}}- type=semver,pattern={{major}}.{{minor}}- type=sha,format=long- latest-- - name: Build and push- uses: docker/build-push-action@v4- with:- context: .- platforms: linux/amd64,linux/arm64/v8- push: ${{ github.event_name != 'pull_request' }}- tags: ${{ steps.meta.outputs.tags }}- labels: ${{ steps.meta.outputs.labels }}- cache-from: type=registry,ref=bestzwei/libretv:buildcache- cache-to: type=registry,ref=bestzwei/libretv:buildcache,mode=maxdiff --git a/Dockerfile b/Dockerfileindex 34992b7..dc3ec9f 100644--- a/Dockerfile+++ b/Dockerfile@@ -1,21 +1,14 @@-# 使用指定的基础镜像,支持 amd64 和 arm64/v8 架构FROM fabiocicerchia/nginx-lua:1.27.5-alpine3.21.3LABEL maintainer="LibreTV Team"LABEL description="LibreTV - 免费在线视频搜索与观看平台"-# 安装必要的工具-RUN apk add --no-cache curl+# 复制应用文件+COPY . /usr/share/nginx/html-# 复制网站文件-COPY . /usr/share/nginx/html/--# 设置工作目录-WORKDIR /usr/share/nginx/html--# 复制自定义 nginx 配置+# 复制Nginx配置文件COPY nginx.conf /etc/nginx/conf.d/default.conf-# 复制并设置入口点脚本权限+# 添加执行权限并设置为入口点脚本COPY docker-entrypoint.sh /RUN chmod +x /docker-entrypoint.sh@@ -25,7 +18,7 @@ EXPOSE 80# 设置入口点ENTRYPOINT ["/docker-entrypoint.sh"]-# 启动命令+# 启动nginxCMD ["nginx", "-g", "daemon off;"]# 健康检查diff --git a/docker-compose.yml b/docker-compose.ymlindex 4b89971..fa042ae 100644--- a/docker-compose.yml+++ b/docker-compose.yml@@ -2,17 +2,15 @@ version: '3'services:libretv:- image: bestzwei/libretv:latest- container_name: libretv+ build:+ context: .+ dockerfile: Dockerfileports:- "8899:80"environment:- - PASSWORD=111111 # 设置密码保护,留空则不启用密码- # - PROXY_API=true # 启用内部API代理,解决跨域问题+ - PASSWORD=your_password_here # 设置密码保护,留空则不启用密码+ # 可以添加其他环境变量restart: unless-stopped+ # 如果您想使用外部卷存储数据# volumes:- # - ./data:/usr/share/nginx/html/data- # 如果希望使用构建模式而非拉取镜像- # build:- # context: .- # dockerfile: Dockerfile\ No newline at end of file+ # - ./data:/usr/share/nginx/html/data\ No newline at end of filediff --git a/docker-entrypoint.sh b/docker-entrypoint.shindex 2fa3118..227e18d 100644--- a/docker-entrypoint.sh+++ b/docker-entrypoint.sh@@ -6,11 +6,6 @@ replace_env_vars() {# Replace the password placeholder in all HTML filesfind /usr/share/nginx/html -type f -name "*.html" -exec sed -i "s/window.__ENV__.PASSWORD = \"{{PASSWORD}}\";/window.__ENV__.PASSWORD = \"${PASSWORD:-}\";/g" {} \;- # Add proxy API environment variable if needed- if [ -n "$PROXY_API" ]; then- find /usr/share/nginx/html -type f -name "*.html" -exec sed -i "s/window.__ENV__.PROXY_API = false;/window.__ENV__.PROXY_API = true;/g" {} \;- fi-echo "Environment variables have been injected into HTML files."}diff --git a/nginx.conf b/nginx.confindex eb2ab33..0f568b8 100644--- a/nginx.conf+++ b/nginx.conf@@ -1,8 +1,6 @@server {listen 80;server_name localhost;- root /usr/share/nginx/html;- index index.html index.htm;#access_log /var/log/nginx/host.access.log main;@@ -49,66 +47,9 @@ server {proxy_pass $target_url;}- # 添加API代理,解决跨域问题- location /api/ {- default_type application/json;- content_by_lua_block {- local http = require "resty.http"- local cjson = require "cjson"- local httpc = http.new()-- -- 获取原始请求的信息- local method = ngx.req.get_method()- local args = ngx.req.get_uri_args()- local target_url = args.url-- if not target_url then- ngx.status = 400- ngx.say(cjson.encode({error = "Missing url parameter"}))- return- end-- -- 移除url参数,保留其他参数- args.url = nil-- -- 设置超时- httpc:set_timeout(5000)-- -- 发送请求- local res, err = httpc:request_uri(target_url, {- method = method,- query = args,- headers = {- ["User-Agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36",- ["Content-Type"] = "application/json"- }- })-- if not res then- ngx.status = 500- ngx.say(cjson.encode({error = "Failed to request: " .. (err or "unknown error")}))- return- end-- -- 返回响应- ngx.status = res.status- for k, v in pairs(res.headers) do- -- 排除一些可能导致问题的头- if k ~= "Transfer-Encoding" and k ~= "Connection" then- ngx.header[k] = v- end- end- ngx.say(res.body)- }- }-- # 静态文件缓存- location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {- expires 7d;- }-location / {- try_files $uri $uri/ /index.html;+ root /usr/share/nginx/html;+ index index.html index.htm;}#error_page 404 /404.html;