diff --git a/.github/workflows/build-nodebb.yml b/.github/workflows/build-nodebb.yml new file mode 100644 index 0000000..869b684 --- /dev/null +++ b/.github/workflows/build-nodebb.yml @@ -0,0 +1,66 @@ +name: Build and Publish Docker Image + +on: + push: + tags: + - "*" + +env: + NODEBB_VERSION: 'v4.7.2' + +jobs: + build-and-push: + runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + submodules: recursive + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Clone NodeBB repository + run: | + git clone --depth=1 https://github.com/NodeBB/NodeBB.git -b ${{ env.NODEBB_VERSION }} NodeBB || true + + - name: Copy build files to NodeBB directory + run: | + cp Dockerfile NodeBB/ || true + cp build.sh NodeBB/ || true + chmod +x NodeBB/build.sh || true + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Get short commit hash + id: vars + run: echo "commit_hash=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + + - name: Prepare Docker image name and tag + run: | + REPO_NAME_LOWERCASE=$(echo "${GITHUB_REPOSITORY}" | tr '[:upper:]' '[:lower:]') + TAG_NAME=$(echo "${GITHUB_REF_NAME}" | tr '[:upper:]' '[:lower:]') + BUILD_TAG="${TAG_NAME}-${{ steps.vars.outputs.commit_hash }}-${GITHUB_RUN_NUMBER}" + + echo "IMAGE_NAME=ghcr.io/${REPO_NAME_LOWERCASE}" >> $GITHUB_ENV + echo "IMAGE_TAG=${BUILD_TAG}" >> $GITHUB_ENV + + echo "Generated Image Name: ${IMAGE_NAME}" + echo "Generated Image Tag: ${IMAGE_TAG}" + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: ./NodeBB + file: ./NodeBB/Dockerfile + push: true + labels: commitHash=${{ steps.vars.outputs.commit_hash }} + tags: ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} diff --git a/Dockerfile b/Dockerfile index 4b674ae..3f3ee77 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,19 +3,17 @@ RUN mkdir -p /usr/src/app WORKDIR /usr/src/app ARG NODE_ENV -ENV NODE_ENV $NODE_ENV +ENV NODE_ENV=$NODE_ENV COPY NodeBB/install/package.json /usr/src/app/package.json COPY NodeBB/ /usr/src/app RUN npm install --only=prod && \ npm cache clean --force - -RUN npm install https://github.com/Sunbird-Lern/nodebb-plugin-sunbird-oidc.git#master -RUN npm install https://github.com/Sunbird-Lern/nodebb-plugin-sunbird-api.git#release-4.6.0 -RUN npm install https://github.com/Sunbird-Lern/nodebb-plugin-sunbird-telemetry.git#master -RUN npm install https://github.com/Sunbird-Lern/nodebb-plugin-azure-storage.git#main -RUN npm install https://github.com/NodeBB/nodebb-plugin-write-api.git#master +RUN npm install https://github.com/Sunbird-Lern/nodebb-plugin-sunbird-oidc.git#develop +RUN npm install https://github.com/Sunbird-Lern/nodebb-plugin-sunbird-api.git#develop +RUN npm install https://github.com/Sunbird-Lern/nodebb-plugin-sunbird-telemetry.git#develop +RUN npm install https://github.com/Sunbird-Lern/nodebb-plugin-azure-storage.git#develop # Nodebb was not taking the latest version of mentions plugin, That's why we added install command here. RUN npm install https://github.com/julianlam/nodebb-plugin-mentions.git#master @@ -40,4 +38,4 @@ EXPOSE 4567 # ENV admin__password="nodebbAdminPassword00" ######################################################## -CMD node ./nodebb setup ; node ./nodebb start +CMD ["node", "./nodebb", "start"]