1
0
Fork 0
mirror of synced 2024-07-02 21:10:43 +12:00

Use nx/esbuild for worker docker & dev

This commit is contained in:
Adria Navarro 2023-05-19 14:45:05 +02:00
parent 37df172ba6
commit f27c4ae55a
8 changed files with 796 additions and 180 deletions

View file

@ -3,7 +3,10 @@
"private": true, "private": true,
"devDependencies": { "devDependencies": {
"@esbuild-plugins/node-resolve": "^0.2.2", "@esbuild-plugins/node-resolve": "^0.2.2",
"@nx/esbuild": "^16.2.1",
"@nx/js": "16.2.1",
"@rollup/plugin-json": "^4.0.2", "@rollup/plugin-json": "^4.0.2",
"@types/node": "18.7.1",
"@typescript-eslint/parser": "5.45.0", "@typescript-eslint/parser": "5.45.0",
"babel-eslint": "^10.0.3", "babel-eslint": "^10.0.3",
"esbuild": "^0.17.18", "esbuild": "^0.17.18",
@ -13,10 +16,10 @@
"husky": "^8.0.3", "husky": "^8.0.3",
"js-yaml": "^4.1.0", "js-yaml": "^4.1.0",
"kill-port": "^1.6.1", "kill-port": "^1.6.1",
"lerna": "^6.6.1", "lerna": "^6.6.2",
"madge": "^6.0.0", "madge": "^6.0.0",
"minimist": "^1.2.8", "minimist": "^1.2.8",
"prettier": "^2.3.1", "prettier": "^2.6.2",
"prettier-plugin-svelte": "^2.3.0", "prettier-plugin-svelte": "^2.3.0",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"rollup-plugin-replace": "^2.2.0", "rollup-plugin-replace": "^2.2.0",
@ -105,5 +108,6 @@
"packages/worker", "packages/worker",
"packages/pro/packages/pro" "packages/pro/packages/pro"
] ]
} },
"dependencies": {}
} }

View file

@ -328,8 +328,8 @@ export const runLuceneQuery = (docs: any[], query?: Query) => {
return ( return (
docValue == null || docValue == null ||
docValue === "" || docValue === "" ||
docValue < testValue.low || +docValue < testValue.low ||
docValue > testValue.high +docValue > testValue.high
) )
} }
) )

View file

@ -7,16 +7,18 @@ LABEL com.centurylinklabs.watchtower.lifecycle.post-check="scripts/watchtower-ho
WORKDIR /app WORKDIR /app
# copy required files
COPY . ./
# handle node-gyp # handle node-gyp
RUN apk add --no-cache --virtual .gyp python3 make g++ \ RUN apk add --no-cache --virtual .gyp python3 make g++
&& yarn && apk del .gyp \
&& yarn \
&& yarn cache clean
RUN yarn global add pm2 RUN yarn global add pm2
COPY dist/package.json .
RUN yarn
RUN apk del .gyp \
&& yarn cache clean
COPY dist/ .
EXPOSE 4001 EXPOSE 4001
# have to add node environment production after install # have to add node environment production after install

View file

@ -6,5 +6,5 @@
"src/**/*.spec.js", "src/**/*.spec.js",
"../backend-core/dist/**/*" "../backend-core/dist/**/*"
], ],
"exec": "node ../../scripts/build && node ./dist/index.js" "exec": "yarn build && node dist/index.cjs"
} }

View file

@ -13,12 +13,11 @@
], ],
"scripts": { "scripts": {
"prebuild": "rimraf dist/", "prebuild": "rimraf dist/",
"build": "node ../../scripts/build.js", "build": "cd ../.. && nx build @budibase/worker",
"check:types": "tsc -p tsconfig.build.json --noEmit", "check:types": "tsc -p tsconfig.build.json --noEmit",
"postbuild": "copyfiles -u 1 src/**/*.hbs dist/",
"build:dev": "yarn prebuild && tsc --build --watch --preserveWatchOutput", "build:dev": "yarn prebuild && tsc --build --watch --preserveWatchOutput",
"run:docker": "node dist/index.js", "run:docker": "node index.cjs",
"debug": "yarn build && node --expose-gc --inspect=9223 dist/index.js", "debug": "yarn build && node --expose-gc --inspect=9223 dist/index.cjs",
"run:docker:cluster": "pm2-runtime start pm2.config.js", "run:docker:cluster": "pm2-runtime start pm2.config.js",
"predocker": "yarn build", "predocker": "yarn build",
"build:docker": "yarn predocker && docker build . -t worker-service --label version=$BUDIBASE_RELEASE_VERSION", "build:docker": "yarn predocker && docker build . -t worker-service --label version=$BUDIBASE_RELEASE_VERSION",

View file

@ -0,0 +1,34 @@
{
"name": "@budibase/worker",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"targets": {
"build": {
"executor": "@nx/esbuild:esbuild",
"outputs": ["{options.outputPath}"],
"defaultConfiguration": "production",
"options": {
"main": "packages/worker/src/index.ts",
"outputPath": "packages/worker/dist",
"outputFileName": "index.js",
"tsConfig": "packages/worker/tsconfig.build.json",
"assets": [
"packages/worker/docker_run.sh",
{
"glob": "**/*.hbs",
"input": "packages/worker/src/constants/templates",
"output": "."
}
],
"format": ["cjs"]
},
"configurations": {
"development": {
"minify": false
},
"production": {
"minify": true
}
}
}
}
}

899
yarn.lock

File diff suppressed because it is too large Load diff