From dc33956028f5fb777b0f1045150a4c675620b7ee Mon Sep 17 00:00:00 2001 From: Pujit Mehrotra Date: Wed, 4 Dec 2024 12:31:56 -0500 Subject: [PATCH 1/3] chore(api): auto-restart dev server on source file changes --- api/Dockerfile | 9 ++++++++- api/package.json | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/api/Dockerfile b/api/Dockerfile index 2c61fa75b7..b4a900b6d3 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -13,7 +13,14 @@ RUN apt-get update -y && apt-get install -y \ jq \ zstd \ git \ - build-essential + build-essential \ + curl + +# Install rust toolchain +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y +ENV PATH="/root/.cargo/bin:${PATH}" + +RUN cargo install --locked watchexec-cli WORKDIR /app diff --git a/api/package.json b/api/package.json index 2a70c5975a..64dbe816e8 100644 --- a/api/package.json +++ b/api/package.json @@ -22,7 +22,7 @@ "test": "vitest run --pool=forks", "coverage": "vitest run --pool=forks --coverage", "release": "standard-version", - "dev": "vite", + "dev": "watchexec -r --stop-signal SIGKILL --exts ts,gql -i \"{node_modules,dist,dev}/**\" vite", "container:build": "./scripts/dc.sh build dev", "container:start": "./scripts/dc.sh run --rm --service-ports dev", "container:test": "./scripts/dc.sh run --rm builder npm run test", From c76a645f6a3ed1c65bf54a651f980f75042f31e4 Mon Sep 17 00:00:00 2001 From: Pujit Mehrotra Date: Wed, 4 Dec 2024 12:37:38 -0500 Subject: [PATCH 2/3] chore(api): decrease container build time via cargo binstall `cargo install` fetches & builds a whole package index, which takes over 1 min. Through `cargo binstall`, we can copy the relevant binary instead, which is much faster (~1 sec). --- api/Dockerfile | 5 +++-- api/package.json | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/api/Dockerfile b/api/Dockerfile index b4a900b6d3..237ba1dfcf 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -19,8 +19,9 @@ RUN apt-get update -y && apt-get install -y \ # Install rust toolchain RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y ENV PATH="/root/.cargo/bin:${PATH}" - -RUN cargo install --locked watchexec-cli +# Install cargo binstall for installing binaries quickly +RUN curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | sh && \ + cargo binstall watchexec-cli WORKDIR /app diff --git a/api/package.json b/api/package.json index 64dbe816e8..2274ba945c 100644 --- a/api/package.json +++ b/api/package.json @@ -22,7 +22,7 @@ "test": "vitest run --pool=forks", "coverage": "vitest run --pool=forks --coverage", "release": "standard-version", - "dev": "watchexec -r --stop-signal SIGKILL --exts ts,gql -i \"{node_modules,dist,dev}/**\" vite", + "dev": "watchexec -r --stop-signal SIGKILL --exts ts,gql -i \"{node_modules,dist,dev,.git,coverage}/**\" vite", "container:build": "./scripts/dc.sh build dev", "container:start": "./scripts/dc.sh run --rm --service-ports dev", "container:test": "./scripts/dc.sh run --rm builder npm run test", From fc6519ebe3bac100a08e24e295b28ec0bf46ef31 Mon Sep 17 00:00:00 2001 From: Pujit Mehrotra Date: Wed, 4 Dec 2024 14:48:12 -0500 Subject: [PATCH 3/3] chore(api): replace watchexec with nodemon --- api/Dockerfile | 10 +- api/package-lock.json | 228 ++++++++++++++++++++++++++++++++++++++++++ api/package.json | 3 +- 3 files changed, 231 insertions(+), 10 deletions(-) diff --git a/api/Dockerfile b/api/Dockerfile index 237ba1dfcf..2c61fa75b7 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -13,15 +13,7 @@ RUN apt-get update -y && apt-get install -y \ jq \ zstd \ git \ - build-essential \ - curl - -# Install rust toolchain -RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y -ENV PATH="/root/.cargo/bin:${PATH}" -# Install cargo binstall for installing binaries quickly -RUN curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | sh && \ - cargo binstall watchexec-cli + build-essential WORKDIR /app diff --git a/api/package-lock.json b/api/package-lock.json index ea9366cc5f..56e9bbea96 100644 --- a/api/package-lock.json +++ b/api/package-lock.json @@ -138,6 +138,7 @@ "eslint": "^9.14.0", "graphql-codegen-typescript-validation-schema": "^0.16.0", "jiti": "^2.4.0", + "nodemon": "^3.1.7", "rollup-plugin-node-externals": "^7.1.3", "standard-version": "^9.5.0", "typescript": "^5.6.3", @@ -10748,6 +10749,13 @@ "node": ">= 4" } }, + "node_modules/ignore-by-default": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz", + "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==", + "dev": true, + "license": "ISC" + }, "node_modules/immer": { "version": "10.0.3", "resolved": "https://registry.npmjs.org/immer/-/immer-10.0.3.tgz", @@ -12380,6 +12388,96 @@ } } }, + "node_modules/nodemon": { + "version": "3.1.7", + "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.7.tgz", + "integrity": "sha512-hLj7fuMow6f0lbB0cD14Lz2xNjwsyruH251Pk4t/yIitCFJbmY1myuLlHm/q06aST4jg6EgAh74PIBBrRqpVAQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "chokidar": "^3.5.2", + "debug": "^4", + "ignore-by-default": "^1.0.1", + "minimatch": "^3.1.2", + "pstree.remy": "^1.1.8", + "semver": "^7.5.3", + "simple-update-notifier": "^2.0.0", + "supports-color": "^5.5.0", + "touch": "^3.1.0", + "undefsafe": "^2.0.5" + }, + "bin": { + "nodemon": "bin/nodemon.js" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/nodemon" + } + }, + "node_modules/nodemon/node_modules/chokidar": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "dev": true, + "license": "MIT", + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/nodemon/node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/nodemon/node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "license": "MIT", + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/nodemon/node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/normalize-package-data": { "version": "2.5.0", "dev": true, @@ -13456,6 +13554,13 @@ "version": "1.9.0", "license": "MIT" }, + "node_modules/pstree.remy": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz", + "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==", + "dev": true, + "license": "MIT" + }, "node_modules/pump": { "version": "3.0.0", "license": "MIT", @@ -14423,6 +14528,19 @@ "resolved": "https://registry.npmjs.org/signedsource/-/signedsource-1.0.0.tgz", "integrity": "sha512-6+eerH9fEnNmi/hyM1DXcRK3pWdoMQtlkQ+ns0ntzunjKqp5i3sKCc80ym8Fib3iaYhdJUOPdhlJWj1tvge2Ww==" }, + "node_modules/simple-update-notifier": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz", + "integrity": "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "semver": "^7.5.3" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/sirv": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/sirv/-/sirv-3.0.0.tgz", @@ -15324,6 +15442,16 @@ "node": ">=6" } }, + "node_modules/touch": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.1.tgz", + "integrity": "sha512-r0eojU4bI8MnHr8c5bNo7lJDdI2qXlWWJk6a9EAFG7vbhTjElYhBVS3/miuE0uOuoLdb8Mc/rVfsmm6eo5o9GA==", + "dev": true, + "license": "ISC", + "bin": { + "nodetouch": "bin/nodetouch.js" + } + }, "node_modules/tough-cookie": { "version": "2.5.0", "license": "BSD-3-Clause", @@ -15642,6 +15770,13 @@ "node": ">=0.10.0" } }, + "node_modules/undefsafe": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz", + "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==", + "dev": true, + "license": "MIT" + }, "node_modules/undici-types": { "version": "5.26.5", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", @@ -23490,6 +23625,12 @@ "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.1.tgz", "integrity": "sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw==" }, + "ignore-by-default": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz", + "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==", + "dev": true + }, "immer": { "version": "10.0.3", "resolved": "https://registry.npmjs.org/immer/-/immer-10.0.3.tgz", @@ -24528,6 +24669,66 @@ } } }, + "nodemon": { + "version": "3.1.7", + "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.7.tgz", + "integrity": "sha512-hLj7fuMow6f0lbB0cD14Lz2xNjwsyruH251Pk4t/yIitCFJbmY1myuLlHm/q06aST4jg6EgAh74PIBBrRqpVAQ==", + "dev": true, + "requires": { + "chokidar": "^3.5.2", + "debug": "^4", + "ignore-by-default": "^1.0.1", + "minimatch": "^3.1.2", + "pstree.remy": "^1.1.8", + "semver": "^7.5.3", + "simple-update-notifier": "^2.0.0", + "supports-color": "^5.5.0", + "touch": "^3.1.0", + "undefsafe": "^2.0.5" + }, + "dependencies": { + "chokidar": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "dev": true, + "requires": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "fsevents": "~2.3.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + } + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "dev": true + }, + "readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "requires": { + "picomatch": "^2.2.1" + } + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, "normalize-package-data": { "version": "2.5.0", "dev": true, @@ -25291,6 +25492,12 @@ "psl": { "version": "1.9.0" }, + "pstree.remy": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz", + "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==", + "dev": true + }, "pump": { "version": "3.0.0", "requires": { @@ -25911,6 +26118,15 @@ "resolved": "https://registry.npmjs.org/signedsource/-/signedsource-1.0.0.tgz", "integrity": "sha512-6+eerH9fEnNmi/hyM1DXcRK3pWdoMQtlkQ+ns0ntzunjKqp5i3sKCc80ym8Fib3iaYhdJUOPdhlJWj1tvge2Ww==" }, + "simple-update-notifier": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz", + "integrity": "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==", + "dev": true, + "requires": { + "semver": "^7.5.3" + } + }, "sirv": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/sirv/-/sirv-3.0.0.tgz", @@ -26512,6 +26728,12 @@ "integrity": "sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==", "dev": true }, + "touch": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.1.tgz", + "integrity": "sha512-r0eojU4bI8MnHr8c5bNo7lJDdI2qXlWWJk6a9EAFG7vbhTjElYhBVS3/miuE0uOuoLdb8Mc/rVfsmm6eo5o9GA==", + "dev": true + }, "tough-cookie": { "version": "2.5.0", "requires": { @@ -26689,6 +26911,12 @@ "unc-path-regex": { "version": "0.1.2" }, + "undefsafe": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz", + "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==", + "dev": true + }, "undici-types": { "version": "5.26.5", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", diff --git a/api/package.json b/api/package.json index 2274ba945c..73d26b65f3 100644 --- a/api/package.json +++ b/api/package.json @@ -22,7 +22,7 @@ "test": "vitest run --pool=forks", "coverage": "vitest run --pool=forks --coverage", "release": "standard-version", - "dev": "watchexec -r --stop-signal SIGKILL --exts ts,gql -i \"{node_modules,dist,dev,.git,coverage}/**\" vite", + "dev": "nodemon --ext ts,gql --ignore \"dist/\" --ignore \"dev/\" --signal SIGKILL --exec \"vite\"", "container:build": "./scripts/dc.sh build dev", "container:start": "./scripts/dc.sh run --rm --service-ports dev", "container:test": "./scripts/dc.sh run --rm builder npm run test", @@ -166,6 +166,7 @@ "eslint": "^9.14.0", "graphql-codegen-typescript-validation-schema": "^0.16.0", "jiti": "^2.4.0", + "nodemon": "^3.1.7", "rollup-plugin-node-externals": "^7.1.3", "standard-version": "^9.5.0", "typescript": "^5.6.3",