Skip to content

Commit

Permalink
Updated build scripts for docker
Browse files Browse the repository at this point in the history
  • Loading branch information
mrinc committed Dec 22, 2023
1 parent 38e7ad1 commit 3027709
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
30 changes: 17 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
11 changes: 5 additions & 6 deletions nodejs/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 3027709

Please sign in to comment.