From 3027709044c0625d748491e487b5cc1dc925567d Mon Sep 17 00:00:00 2001 From: mrinc Date: Fri, 22 Dec 2023 22:28:18 +0200 Subject: [PATCH] Updated build scripts for docker --- .github/workflows/release.yml | 30 +++++++++++++++++------------- nodejs/Dockerfile | 11 +++++------ 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 633c936..5a158c0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -29,22 +29,22 @@ jobs: - name: Checkout uses: actions/checkout@v2 - - run: mkdir ./ci-build-dist - working-directory: ./nodejs + # - run: mkdir ./ci-build-dist + # working-directory: ./nodejs - - name: Download artifact - uses: actions/download-artifact@v4 - with: - name: node-${{ needs.build_nodejs_plugin_release.outputs.tag }}-${{ needs.build_nodejs_plugin_release.outputs.version }} - path: ./nodejs/ci-build-dist/ + # - name: Download artifact + # uses: actions/download-artifact@v4 + # with: + # name: node-${{ needs.build_nodejs_plugin_release.outputs.tag }}-${{ needs.build_nodejs_plugin_release.outputs.version }} + # path: ./nodejs/ci-build-dist/ - - name: Extract artifact - working-directory: ./nodejs - run: | - tar -xzf ./ci-build-dist/as-built.tar.gz -C ./ + # - name: Extract artifact + # working-directory: ./nodejs + # run: | + # tar -xzf ./ci-build-dist/as-built.tar.gz -C ./ - - run: rm -rfv ./ci-build-dist - working-directory: ./nodejs + # - run: rm -rfv ./ci-build-dist + # working-directory: ./nodejs - name: Set up QEMU uses: docker/setup-qemu-action@master @@ -65,6 +65,8 @@ jobs: uses: docker/build-push-action@v5 if: needs.build_nodejs_plugin_release.outputs.tag != 'latest' with: + build-args: | + BSB_VERSION=${{ needs.build_nodejs_plugin_release.outputs.version }} builder: ${{ steps.buildx.outputs.name }} context: ./nodejs/ file: ./nodejs/Dockerfile @@ -80,6 +82,8 @@ jobs: uses: docker/build-push-action@v5 if: needs.build_nodejs_plugin_release.outputs.tag == 'latest' with: + build-args: | + BSB_VERSION=${{ needs.build_nodejs_plugin_release.outputs.version }} builder: ${{ steps.buildx.outputs.name }} context: ./nodejs/ file: ./nodejs/Dockerfile diff --git a/nodejs/Dockerfile b/nodejs/Dockerfile index fb709fa..af01806 100644 --- a/nodejs/Dockerfile +++ b/nodejs/Dockerfile @@ -1,6 +1,8 @@ # BSB Build FROM betterweb/node:20 as builder +ARG BSB_VERSION=0.0.0 + RUN set -eux && mkdir /home/bsb && npm i -g typescript ts-node WORKDIR /home/bsb @@ -9,14 +11,15 @@ ADD tsconfig-release.json /home/bsb/tsconfig-release.json ADD package.json /home/bsb/package.json ADD package-lock.json /home/bsb/package-lock.json ADD src/ /home/bsb/src/ -RUN npm ci -RUN npm run build-release +RUN npm ci && npm version $BSB_VERSION --allow-same-version --no-git-tag-version && npm run build-release # Final image FROM betterweb/node:20 COPY --from=builder /home/bsb/lib /home/bsb/lib COPY --from=builder /home/bsb/node_modules /home/bsb/node_modules +COPY --from=builder /home/bsb/package.json /home/bsb/package.json +COPY --from=builder /home/bsb/package-lock.json /home/bsb/package-lock.json VOLUME /mnt/bsb-plugins WORKDIR /home/bsb @@ -26,10 +29,6 @@ ENV BSB_LIVE true ENV BSB_CONTAINER true ENV BSB_PLUGIN_DIR /mnt/bsb-plugins -ADD package.json /home/bsb/package.json -ADD package-lock.json /home/bsb/package-lock.json -ADD lib/ /home/bsb/lib/ - COPY entrypoint.sh /root/entrypoint.sh RUN addgroup node dialout && touch /home/bsb/sec-config.yaml && chown -R root:node /home/bsb && chmod -R 650 /home/bsb && chown node:node /home/bsb/sec-config.yaml && chmod +x /root/entrypoint.sh