support docker

This commit is contained in:
我若为王 2024-12-05 13:18:54 +08:00
parent 91aaffc136
commit 3d9f3379a2
2 changed files with 73 additions and 0 deletions

49
.github/workflows/docker-build.yml vendored Normal file
View File

@ -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

24
Dockerfile Normal file
View File

@ -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"]