mirror of
https://github.com/hpware/news-analyze.git
synced 2025-06-23 15:51:01 +08:00
Update caching & docker compose
This commit is contained in:
parent
8975812447
commit
bd7ac3367f
53
.github/workflows/build_docker_image.yml
vendored
Normal file
53
.github/workflows/build_docker_image.yml
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
name: Build and Push Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ["main"]
|
||||
pull_request:
|
||||
branches: ["main"]
|
||||
|
||||
env:
|
||||
REGISTRY: ghcr.io
|
||||
IMAGE_NAME: ${{ github.repository }}
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Log in to the Container registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Extract metadata (tags, labels) for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=ref,event=pr
|
||||
type=semver,pattern={{version}}
|
||||
type=sha,prefix=
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
34
.github/workflows/self_deploy.yml
vendored
34
.github/workflows/self_deploy.yml
vendored
@ -1,34 +0,0 @@
|
||||
name: Server Deployment Request
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
env:
|
||||
DEPLOY_URL: ${{ secrets.DEPLOY_URL }}
|
||||
|
||||
steps:
|
||||
- name: Send deployment request
|
||||
id: deploy-request
|
||||
run: |
|
||||
echo "Sending deployment request to server..."
|
||||
RESPONSE=$(curl -X POST \
|
||||
-H "Content-Type: application/json" \
|
||||
--http1.1 \
|
||||
--fail \
|
||||
--silent \
|
||||
--show-error \
|
||||
"${{ secrets.DEPLOY_URL }}" || echo "Failed to send request")
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Deployment request sent successfully"
|
||||
echo "Response: $RESPONSE"
|
||||
else
|
||||
echo "Error sending deployment request"
|
||||
exit 1
|
||||
fi
|
@ -1,15 +1,19 @@
|
||||
version: "3.8"
|
||||
|
||||
services:
|
||||
newsanalyze-service:
|
||||
build: .
|
||||
ports:
|
||||
- "127.0.0.1:36694:3000"
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
restart: unless-stopped
|
||||
image: ghcr.io/hpware/news-analyze:latest
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:3000"]
|
||||
interval: 30s
|
||||
test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
|
||||
interval: 1m
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
networks:
|
||||
- app-network
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
- "traefik.http.routers.newsanalyze.rule=Host(`news.yuanhau.com`)"
|
||||
- "traefik.http.routers.newsanalyze.entrypoints=webinternal"
|
||||
- "traefik.http.services.newsanalyze.loadbalancer.server.port=3000"
|
||||
|
||||
networks:
|
||||
web:
|
||||
external: true
|
||||
|
@ -1,29 +0,0 @@
|
||||
services:
|
||||
internal-proxy:
|
||||
image: traefik:latest
|
||||
command:
|
||||
- --entrypoints.webinternal.address=:80
|
||||
ports:
|
||||
- "127.0.0.1:36694:80"
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
networks:
|
||||
- app-network
|
||||
newsanalyze-service:
|
||||
build: .
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
|
||||
interval: 1m
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
networks:
|
||||
- app-network
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
- "traefik.http.routers.newsanalyze.rule=Host(`news.yuanhau.com`)"
|
||||
- "traefik.http.routers.newsanalyze.entrypoints=webinternal"
|
||||
- "traefik.http.services.newsanalyze.loadbalancer.server.port=3000"
|
||||
|
||||
networks:
|
||||
app-network:
|
||||
driver: bridge
|
@ -18,6 +18,7 @@ export default defineNuxtConfig({
|
||||
redirect: "https://s3.yhw.tw/data/def-zip-bomb/wp-login.php.zip",
|
||||
},
|
||||
"/api/cached/**": { swr: 3600 },
|
||||
"/api/news/get": { swr: 3600 },
|
||||
},
|
||||
|
||||
css: ["~/styles/main.css"],
|
||||
|
Loading…
x
Reference in New Issue
Block a user