diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 0000000..52706cc --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,49 @@ + +name: Build and Push Docker Image + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Log into GHCR + uses: docker/login-action@master + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ github.token }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - 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: . + platforms: linux/amd64,linux/arm64,linux/s390x + file: ./Dockerfile + push: true + tags: ghcr.io/${{ github.repository_owner }}/alipan-tv-token:latest + + - name: Post build cleanup + run: docker builder prune --force \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0bbc1bb --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ + +# 使用官方的 Node.js 镜像作为基础镜像 +FROM node:18-alpine + +# 设置工作目录 +WORKDIR /app + +# 复制 package.json 和 package-lock.json(如果有)到工作目录 +COPY package*.json ./ + +# 安装项目依赖 +RUN npm install + +# 复制项目文件到工作目录 +COPY . . + +# 构建项目(如果需要) +RUN npm run build + +# 暴露应用运行的端口(假设应用运行在 3000 端口) +EXPOSE 3000 + +# 启动应用 +CMD ["npm", "start"] \ No newline at end of file