From 4e83153cc588db91b7d38265b2ca23f0d993b52f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E4=BF=9D=E7=A5=A5?= Date: Fri, 22 Nov 2024 01:12:52 +0800 Subject: [PATCH] build --- .github/workflows/build.yml | 18 ++++++++++++++---- Dockerfile | 15 +++++++++++++++ 2 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 Dockerfile diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dc89bea..8f8e10e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,8 +30,7 @@ jobs: sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10 --slave /usr/bin/gcov gcov /usr/bin/gcov-10 - run: npm install --ignore-scripts - run: npm run build - - if: ${{github.event.inputs.job == 'build-push'}} - run: npm publish + - run: npm publish env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} push-docker: @@ -41,8 +40,15 @@ jobs: DOCKER_REPO: ${{ secrets.DOCKER_USERNAME }}/filecat DOCKER_PLATFORMS: linux/amd64,linux/arm,linux/arm64 # 目标平台 steps: - - name: Checkout - uses: actions/checkout@v4 + - uses: actions/checkout@v4 # 使用社区的指令 + - uses: actions/setup-node@v4 + with: + node-version: 18 + registry-url: https://registry.npmjs.org + - run: | + sudo apt update + sudo apt install gcc-10 g++-10 -y + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10 --slave /usr/bin/gcov gcov /usr/bin/gcov-10 - name: Docker meta # 镜像仓库 id: meta uses: docker/metadata-action@v5 @@ -54,6 +60,10 @@ jobs: uses: docker/setup-qemu-action@v3 - name: Set up Docker buildx uses: docker/setup-buildx-action@v3 + - name: build + run: | + npm install --ignore-scripts + npm run docker-build - name: Login to Docker Hub # login to Docker Hub, automatically logout at the end of job uses: docker/login-action@v3 with: diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..bb1f85b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM node:hydrogen-alpine3.20 + +WORKDIR /app + +COPY env /app/env +COPY /build /app +#COPY /node_modules /app/node_modules +#COPY filecat-linux /app/filecat-linux +# 给 filecat-linux 添加执行权限 +RUN #chmod +x /app/filecat-linux + +EXPOSE 5567 +ENTRYPOINT ["node","/app/main.js"] +# 默认参数 有参数会被覆盖 +CMD ["--env", "/app/env"] \ No newline at end of file