-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a967608
commit 4813572
Showing
16 changed files
with
5,374 additions
and
10,008 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ README.md | |
.linterstagedrc.json | ||
jest.config.js | ||
.env.example | ||
.husky |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
{ | ||
"env": { | ||
"mocha": true, | ||
"node": true, | ||
"jest": true, | ||
}, | ||
|
||
"globals": { | ||
"BufferEncoding": "readonly", | ||
}, | ||
|
||
"root": true, | ||
|
||
"plugins": ["@typescript-eslint", "json", "promise", "import", "prettier"], | ||
|
||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:node/recommended", | ||
"plugin:json/recommended", | ||
"plugin:promise/recommended", | ||
"plugin:import/typescript", | ||
"prettier", | ||
], | ||
|
||
"settings": { | ||
"import/resolver": { | ||
"typescript": true, | ||
"node": true, | ||
}, | ||
"import/parsers": { | ||
"@typescript-eslint/parser": [".ts"], | ||
}, | ||
}, | ||
|
||
"parser": "@typescript-eslint/parser", | ||
|
||
"rules": { | ||
"node/no-missing-import": "off", | ||
"node/no-unpublished-import": "off", | ||
"prettier/prettier": "warn", | ||
"import/order": [ | ||
"warn", | ||
{ | ||
"alphabetize": { | ||
"order": "asc", | ||
"caseInsensitive": true, | ||
}, | ||
}, | ||
], | ||
"sort-vars": ["warn", { "ignoreCase": true }], | ||
"no-unused-vars": "off", | ||
"@typescript-eslint/no-unused-vars": "error", | ||
"import/no-unresolved": "error", | ||
}, | ||
|
||
"ignorePatterns": ["dist", "**/*.d.ts"], | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
npm run typecheck; | ||
npx lint-staged; | ||
make pre-commit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
npm run lint; | ||
npm run typecheck; | ||
npm run test; | ||
make pre-push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,27 @@ | ||
# Install dependencies only when needed | ||
FROM node:18-alpine AS deps | ||
FROM node:20-alpine AS deps | ||
|
||
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. | ||
RUN apk add --no-cache libc6-compat | ||
WORKDIR /app | ||
|
||
# Install dependencies | ||
COPY package.json package-lock.json* ./ | ||
RUN npm ci | ||
RUN npm ci --legacy-peer-deps | ||
|
||
# Rebuild the source code only when needed | ||
FROM node:18-alpine AS builder | ||
FROM node:20-alpine | ||
RUN apk update && apk add --no-cache make && apk add --no-cache bash | ||
WORKDIR /app | ||
COPY . . | ||
COPY --from=deps /app/node_modules ./node_modules | ||
|
||
ENV NODE_ENV production | ||
RUN npm run build | ||
|
||
# Run code from build with proper user | ||
FROM node:18-alpine | ||
WORKDIR /app | ||
COPY --from=deps /app/node_modules ./node_modules | ||
COPY --from=builder /app/dist ./ | ||
|
||
ENV NODE_ENV production | ||
ARG NODE_ENV | ||
ENV NODE_ENV=${NODE_ENV} | ||
|
||
RUN addgroup --system --gid 1001 nodejs | ||
RUN adduser --system --uid 1001 automation-nodejs | ||
RUN adduser --system --uid 1001 prod-nodejs | ||
|
||
USER automation-nodejs | ||
USER prod-nodejs | ||
|
||
CMD ["node", "index.js"] | ||
CMD ["make", "prod"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
SHELL := /bin/bash | ||
|
||
.PHONY: init typecheck lint lint-stg test pre-commit pre-push builddev updev watch stopdev cleandev buildprod upprod cleanprod dev prod | ||
|
||
all: init typecheck test | ||
|
||
init: | ||
@npm i --legacy-peer-deps | ||
|
||
typecheck: | ||
@npx tsc --project tsconfig.json | ||
|
||
lint: | ||
@npx eslint src/**/*.ts | ||
|
||
lint-stg: | ||
@npx lint-staged | ||
|
||
test: | ||
@npx jest --passWithNoTests | ||
|
||
pre-commit: typecheck lint-stg | ||
|
||
pre-push: lint typecheck test | ||
|
||
# docker aliases | ||
|
||
builddev: | ||
@docker compose build | ||
|
||
updev: | ||
@docker compose up -d && docker compose logs -f | ||
|
||
watch: | ||
@docker compose up -d --watch && docker compose logs -f | ||
|
||
stopdev: | ||
@docker compose stop | ||
|
||
cleandev: | ||
@docker compose down | ||
|
||
buildprod: | ||
@docker compose -f docker-compose.prod.yml build | ||
|
||
upprod: | ||
@docker compose -f docker-compose.prod.yml up -d && docker compose logs -f | ||
|
||
cleanprod: | ||
@docker compose -f docker-compose.prod.yml down | ||
|
||
# shortcuts for docker | ||
prod : | ||
@npx tsx src | ||
|
||
dev: | ||
@npx dotenvx run -- tsx --watch src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
version: "3.7" | ||
|
||
services: | ||
automation-node-prod: | ||
hostname: automation-node-prod | ||
image: automation-node-prod | ||
restart: always | ||
build: | ||
context: . | ||
args: | ||
- NODE_ENV=production | ||
logging: | ||
driver: "json-file" | ||
options: | ||
max-file: "5" | ||
max-size: "100m" | ||
secrets: | ||
master_key: | ||
file: .env.keys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
version: "3.7" | ||
|
||
services: | ||
automation-node: | ||
hostname: automation-node | ||
image: automation-node | ||
automation-node-develop: | ||
hostname: automation-node-develop | ||
image: automation-node-develop | ||
restart: always | ||
build: | ||
context: . | ||
logging: | ||
driver: "json-file" | ||
options: | ||
max-file: "5" | ||
max-size: "100m" | ||
environment: | ||
- NODE_PK=${NODE_PK} | ||
- RPC=${RPC} | ||
- WS_RPC=${WS_RPC} | ||
- NETWORK=${NETWORK} | ||
args: | ||
- NODE_ENV=develop | ||
command: ["make", "dev"] | ||
develop: | ||
watch: | ||
# sync static content | ||
- path: ./src | ||
action: sync | ||
target: /app | ||
ignore: | ||
- node_modules/ |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"testPathIgnorePatterns": ["dist"], | ||
"moduleNameMapper": { | ||
"^(\\.{1,2}/.*)\\.js$": "$1" | ||
}, | ||
"extensionsToTreatAsEsm": [".ts"], | ||
"transform": { | ||
"^.+\\.(mt|t|cj|j)s$": [ | ||
"ts-jest", | ||
{ | ||
"useESM": true | ||
} | ||
] | ||
} | ||
} |
Oops, something went wrong.