4 Commits

Author SHA1 Message Date
imsyy
11addd20ca 🐳 chore: 修复工作流 2024-06-07 09:07:09 +08:00
imsyy
23375519ba 🐳 chore: 修复工作流 2024-06-06 17:50:06 +08:00
imsyy
2ba46c5e0e 🐳 chore: 修复工作流 2024-06-06 17:31:20 +08:00
imsyy
d4a52a6b24 🐞 fix: 修复 Docker 运行出错 2024-06-06 16:27:01 +08:00
7 changed files with 33 additions and 13 deletions

View File

@@ -3,9 +3,10 @@ name: Publish Docker image
on:
release:
types: [published]
workflow_dispatch:
jobs:
push_to_registry:
build-docker:
name: Push Docker image to multiple registries
runs-on: ubuntu-latest
permissions:
@@ -15,6 +16,12 @@ jobs:
- name: Check out the repo
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
@@ -36,11 +43,14 @@ jobs:
imsyy/dailyhot-api
ghcr.io/${{ github.repository }}
- name: Build and push Docker image
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: |
linux/amd64
linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

View File

@@ -1,8 +1,14 @@
FROM node:20-alpine AS base
# 安装 Puppeteer 所需的依赖库
RUN apk add --no-cache chromium nss freetype harfbuzz ca-certificates libc6-compat
# 配置 Chromium
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
FROM base AS builder
RUN apk add --no-cache libc6-compat
RUN npm install -g pnpm
WORKDIR /app
@@ -10,9 +16,9 @@ COPY package*json tsconfig.json pnpm-lock.yaml .env ./
COPY src ./src
COPY public ./public
RUN pnpm install && \
pnpm build && \
pnpm prune --production
RUN pnpm install
RUN pnpm build
RUN pnpm prune --production
FROM base AS runner
WORKDIR /app

View File

@@ -2,6 +2,12 @@
<img alt="logo" height="120" src="./public/favicon.png" width="120"/>
<h2>今日热榜</h2>
<p>一个聚合热门数据的 API 接口</p>
<br />
<img src="https://img.shields.io/github/last-commit/imsyy/DailyHotApi" alt="last commit"/>
<img src="https://img.shields.io/github/languages/code-size/imsyy/DailyHotApi" alt="code size"/>
<img src="https://img.shields.io/docker/image-size/imsyy/dailyhot-api" alt="docker-image-size"/>
<img src="https://github.com/imsyy/DailyHotApi/actions/workflows/docker.yml/badge.svg" alt="Publish Docker image"/>
<img src="https://github.com/imsyy/DailyHotApi/actions/workflows/npm.yml/badge.svg" alt="Publish npm package"/>
</div>
## 🚩 特性

View File

@@ -1,6 +1,6 @@
{
"name": "dailyhot-api",
"version": "2.0.0-rc.4",
"version": "2.0.0-rc.5",
"description": "An Api on Today's Hot list",
"keywords": [
"API",
@@ -17,7 +17,7 @@
"license": "MIT",
"author": "imsyy",
"main": "dist/index.js",
"types": "dist/types.js",
"types": "src/types.d.ts",
"declaration": true,
"declarationMap": true,
"sourceMap": true,

View File

@@ -10,8 +10,8 @@ const serveHotApi = (port: number = config.PORT) => {
fetch: app.fetch,
port,
});
logger.info(`🔥 DailyHot API 成功在端口 ${config.PORT} 上运行`);
logger.info(`🔗 Local: 👉 http://localhost:${config.PORT}`);
logger.info(`🔥 DailyHot API 成功在端口 ${port} 上运行`);
logger.info(`🔗 Local: 👉 http://localhost:${port}`);
return apiServer;
} catch (error) {
logger.error(error);

View File

@@ -31,7 +31,7 @@ const getList = async (options: Options, noCache: boolean) => {
const { type } = options;
const url = `https://www.v2ex.com/api/topics/${type}.json`;
const result = await get({ url, noCache });
const list = result.data.data.list;
const list = result.data;
return {
fromCache: result.fromCache,
updateTime: result.updateTime,

View File

@@ -30,8 +30,6 @@ const getList = async (options: Options, noCache: boolean) => {
const url = `http://www.nmc.cn/rest/findAlarm?pageNo=1&pageSize=20&signaltype=&signallevel=&province=${encodeURIComponent(province)}`;
const result = await get({ url, noCache });
const list = result.data.data.page.list;
console.log(list);
return {
fromCache: result.fromCache,
updateTime: result.updateTime,