From 121a8626a8e247c01cd09c60be5fec3921e3f3a1 Mon Sep 17 00:00:00 2001 From: "C.Lee Taylor" <47312074+leet4tari@users.noreply.github.com> Date: Wed, 30 Aug 2023 10:13:59 +0200 Subject: [PATCH] Add node env overrides, basic GitHub Actions, start of docker build (#12) --- .dockerignore | 9 +++++++ .github/ISSUE_TEMPLATE/bug_report.md | 36 ++++++++++++++++++++++++++++ .github/PULL_REQUEST_TEMPLATE.md | 27 +++++++++++++++++++++ .github/dependabot.yml | 8 +++++++ .github/workflows/pr_title.yml | 30 +++++++++++++++++++++++ Dockerfile | 20 ++++++++++++++++ README.md | 9 +++++-- baseNodeClient.js | 2 +- 8 files changed, 138 insertions(+), 3 deletions(-) create mode 100644 .dockerignore create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/pr_title.yml create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..5c3de98 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,9 @@ +.dockerignore +Dockerfile + +node_modules +npm-debug.log +.npmrc + +.git +.gitignore diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..c403e78 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,36 @@ +--- +name: Bug report +about: Create a report to help us improve +title: "[TITLE]" +labels: 'bug-report' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Desktop (please complete the following information):** + - OS & Version: [e.g. iOS 10.2.1] + - Browser & Version [e.g. chrome v71.0.12345] + +**Smartphone (please complete the following information):** + - Device: [e.g. iPhone6] + - OS: [e.g. iOS8.1] + - Browser & Version [e.g. stock browser v0.1.2] + +**Additional context** +Add any other context about the problem here. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..ac0792f --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,27 @@ +Description +--- + +Motivation and Context +--- + +How Has This Been Tested? +--- + +What process can a PR reviewer use to test or verify this change? +--- + + + + + +Breaking Changes +--- + +- [x] None +- [ ] Requires data directory on base node to be deleted +- [ ] Requires hard fork +- [ ] Other - Please specify + + + diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..567c3fd --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,8 @@ +--- +version: 2 +updates: + # Maintain dependencies for GitHub Actions + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" diff --git a/.github/workflows/pr_title.yml b/.github/workflows/pr_title.yml new file mode 100644 index 0000000..ae85f6b --- /dev/null +++ b/.github/workflows/pr_title.yml @@ -0,0 +1,30 @@ +--- +# Checks that PR titles conform to Conventional Commits +# See https://www.conventionalcommits.org/en/v1.0.0/ for more information +name: PR + +'on': + pull_request: + types: + - opened + - reopened + - edited + - synchronize + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + check-title: + runs-on: ubuntu-latest + steps: + - name: install + run: | + npm install -g @commitlint/cli @commitlint/config-conventional + echo "module.exports = {extends: ['@commitlint/config-conventional']}" > commitlint.config.js + - name: lint + run: | + echo "$PR_TITLE" | commitlint + env: + PR_TITLE: ${{github.event.pull_request.title}} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1b9669f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +FROM node:16.17.0-bullseye-slim + +RUN apt-get update && \ + apt-get install -y --no-install-recommends dumb-init + +ENV NODE_ENV production +WORKDIR /usr/src/app +COPY --chown=node:node . . +#RUN npm ci --only=production --omit=dev libs/base_node_grpc_client +#RUN npm ci --only=production --omit=dev +RUN npm install ./libs/base_node_grpc_client/ +RUN npm install +RUN npm install debug + +EXPOSE 4000 + +USER node +#CMD ["dumb-init", "node", "app.js"] +#CMD ["npm", "start"] +CMD ["dumb-init", "node", "./bin/www"] diff --git a/README.md b/README.md index 042872e..491df48 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ # Tari explorer -## No client-side JavaScript block explorer +## No client-side JavaScript block explorer (tari-text-explorer) ### Dependencies -- `npm i` +- `npm install` ### Development (nodemon reload) @@ -13,3 +13,8 @@ ### Start server - `npm start` + +## Useful environment variables + +- PORT:4000 'Port of service' +- BASE_NODE_GRPC_URL:localhost:18142 'Base node GRPC URL' diff --git a/baseNodeClient.js b/baseNodeClient.js index 32d37cb..3a41cbf 100644 --- a/baseNodeClient.js +++ b/baseNodeClient.js @@ -4,7 +4,7 @@ var { Client } = require("base-node-grpc-client"); function createClient() { - return Client.connect("localhost:18142"); + return Client.connect( process.env.BASE_NODE_GRPC_URL || "localhost:18142"); } module.exports = {