From bd062adf2ae66925b189693d50014b07ffd6dee0 Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 21 Dec 2023 15:29:47 +0100 Subject: [PATCH] refs #5739 feat: autoinstall node_modules --- back/{Dockerfile.local => Dockerfile} | 30 +++++- back/Dockerfile.test | 9 -- back/runTestBack.sh | 2 + docker-compose.local.yml | 20 +++- docker-compose.test.yml | 24 ++++- front/Dockerfile.local | 5 +- front/package.json | 1 - init.sh | 1 + package-lock.json | 134 ++++++++++++++++++++++++++ package.json | 3 +- 10 files changed, 203 insertions(+), 26 deletions(-) rename back/{Dockerfile.local => Dockerfile} (67%) delete mode 100644 back/Dockerfile.test create mode 100644 back/runTestBack.sh create mode 100644 init.sh diff --git a/back/Dockerfile.local b/back/Dockerfile similarity index 67% rename from back/Dockerfile.local rename to back/Dockerfile index d7c06204e..164a1d7b3 100644 --- a/back/Dockerfile.local +++ b/back/Dockerfile @@ -1,4 +1,4 @@ -FROM node:20-bullseye-slim +FROM node:20-bullseye as base ENV TZ Europe/Madrid ARG DEBIAN_FRONTEND=noninteractive @@ -20,16 +20,26 @@ RUN apt-get update \ && apt-get install -y --no-install-recommends \ samba-common-bin samba-dsdb-modules\ && rm -rf /var/lib/apt/lists/* +# RUN apt update && apt install -y chromium-browser chromium-chromedriver + +# RUN curl -fsSL https://bun.sh/install | bash # Salix WORKDIR /salix +# COPY package.json package-lock.json ./ +# COPY loopback/package.json loopback/ +# COPY print/package.json print/ +# # RUN npm install +# # RUN npm install +# # RUN npm --prefix ./print install ./print + COPY print/package.json print/package-lock.json print/ RUN npm --prefix ./print install ./print COPY package.json package-lock.json ./ COPY loopback/package.json loopback/ -RUN npm install --ci +RUN npm install COPY gulpfile.js ./ COPY \ @@ -37,7 +47,19 @@ COPY \ README.md \ ./ -FROM scratch -WORKDIR /salix +FROM base AS local CMD ["npx", "gulp", "backWatch"] + + +FROM base AS test + +COPY loopback loopback +COPY back back +COPY modules modules +COPY print print +COPY storage storage + +# CMD ["npx", "gulp", "backOnly"] +CMD ["npm", "run", "test:back:ci"] + diff --git a/back/Dockerfile.test b/back/Dockerfile.test deleted file mode 100644 index 4654f9270..000000000 --- a/back/Dockerfile.test +++ /dev/null @@ -1,9 +0,0 @@ -FROM back:local - -COPY loopback loopback -COPY back back -COPY modules modules -COPY print print -COPY storage storage - -CMD ["npx", "gulp", "backOnly"] diff --git a/back/runTestBack.sh b/back/runTestBack.sh new file mode 100644 index 000000000..0edf1eeb4 --- /dev/null +++ b/back/runTestBack.sh @@ -0,0 +1,2 @@ +docker-compose -p salix-test -f docker-compose.test.yml build --no-cache back db +docker-compose -p salix-test -f docker-compose.test.yml run --rm back diff --git a/docker-compose.local.yml b/docker-compose.local.yml index dfad91b51..efd6d7abb 100644 --- a/docker-compose.local.yml +++ b/docker-compose.local.yml @@ -1,7 +1,14 @@ version: "3.7" services: + # node_modules: + # image: node:20-bullseye-slim + # command: npm install --ci + # user: "${UID}:${GID}" + # working_dir: /salix + # volumes: + # - .:/salix db: - image: db:local + image: db restart: unless-stopped build: context: db @@ -9,7 +16,7 @@ services: ports: - 3306:3306 front: - image: front:local + image: front restart: unless-stopped build: context: . @@ -25,23 +32,26 @@ services: - ./loopback:/salix/loopback back: - image: back:local + image: back restart: unless-stopped build: context: . - dockerfile: back/Dockerfile.local + dockerfile: back/Dockerfile + target: local ports: - 3000:3000 environment: - NODE_ENV depends_on: - db + # - node_modules volumes: - ./loopback:/salix/loopback - ./storage:/salix/storage - ./modules:/salix/modules - ./back:/salix/back - - ./print:/salix/print + # - ./node_modules:/salix/node_modules + # - ./print:/salix/print networks: salix-stack-network: diff --git a/docker-compose.test.yml b/docker-compose.test.yml index 9baf7ffca..b9d449b45 100644 --- a/docker-compose.test.yml +++ b/docker-compose.test.yml @@ -1,7 +1,19 @@ version: "3.7" services: + # node_modules: + # image: node:20-bullseye-slim + # command: npm install --ci + # working_dir: /salix + # volumes: + # - .:/salix + # print: + # image: node:20-bullseye-slim + # # command: cd print && npm install --ci + # working_dir: /salix/print + # volumes: + # - ./print:/salix/print db: - image: salix-db + image: salix-db:test restart: always build: context: db @@ -18,14 +30,20 @@ services: back: image: salix-back restart: always - command: ["npm", "run", "test:back:ci"] build: context: . - dockerfile: back/Dockerfile.test + dockerfile: back/Dockerfile + target: test environment: - NODE_ENV depends_on: - db + - node_modules + - print + volumes: + - ./node_modules:/salix/node_modules + - ./print/node_modules:/salix/print/node_modules + networks: salix-stack-network: diff --git a/front/Dockerfile.local b/front/Dockerfile.local index 21f144672..7e508362f 100644 --- a/front/Dockerfile.local +++ b/front/Dockerfile.local @@ -1,10 +1,9 @@ -FROM salix-back +FROM back EXPOSE 5000 COPY /front/gulpfile.js ./ COPY /front/webpack.config.js ./ COPY /front/package.json ./front/ - -RUN cd front && npm install --ci +# RUN cd front && npm install --ci CMD ["npx", "gulp", "front"] diff --git a/front/package.json b/front/package.json index ba1012176..77af30f6c 100644 --- a/front/package.json +++ b/front/package.json @@ -4,7 +4,6 @@ "author": "Verdnatura Levante SL", "description": "Salix frontend", "license": "GPL-3.0", - "type": "module", "repository": { "type": "git", "url": "https://gitea.verdnatura.es/verdnatura/salix" diff --git a/init.sh b/init.sh new file mode 100644 index 000000000..22a487bbb --- /dev/null +++ b/init.sh @@ -0,0 +1 @@ +docker run --rm -v $(pwd):/app -w /app node:20-bullseye-slim npm install diff --git a/package-lock.json b/package-lock.json index 78ef93987..12bd0f5bd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,6 +13,7 @@ "base64url": "^3.0.1", "bcrypt": "^5.0.1", "bmp-js": "^0.1.0", + "chrome": "^0.1.0", "compression": "^1.7.3", "form-data": "^4.0.0", "fs-extra": "^5.0.0", @@ -5572,6 +5573,18 @@ "version": "1.1.4", "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==" }, + "node_modules/chrome": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/chrome/-/chrome-0.1.0.tgz", + "integrity": "sha512-6KYl20U4Taj6YipylsWr2etUvp9AElJKfGNSBmyGTymYmancnOb041ZNadolEZi2nboLXH7jMSqUmm4kpuTzfg==", + "dependencies": { + "exeq": "^2.2.0", + "plist": "^1.1.0" + }, + "bin": { + "chrome": "index.js" + } + }, "node_modules/chrome-trace-event": { "version": "1.0.3", "integrity": "sha512-p3KULyQg4S7NIHixdwbGX+nFHkoBiA4YQmyWtjb8XngSKV124nJmRysgAeujbUVb15vh+RvFUfCPqU7rXk+hZg==", @@ -7971,6 +7984,18 @@ "version": "2.0.0", "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==" }, + "node_modules/exeq": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/exeq/-/exeq-2.4.0.tgz", + "integrity": "sha512-B648qbDS00nQZv9UQGLT5RbZm/5dNBX10F8oWeXcgpFHSLm1249u95t/3sn2wXdQjLhlF+edAECdshFtSr1K0Q==", + "dependencies": { + "bluebird": "^3.0.3", + "native-or-bluebird": "^1.2.0" + }, + "engines": { + "node": ">= 0.10.0" + } + }, "node_modules/exit": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", @@ -17437,6 +17462,12 @@ "node": ">=0.10.0" } }, + "node_modules/native-or-bluebird": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/native-or-bluebird/-/native-or-bluebird-1.2.0.tgz", + "integrity": "sha512-0SH8UubxDfe382eYiwmd12qxAbiWGzlGZv6CkMA+DPojWa/Y0oH4hE0lRtFfFgJmPQFyKXeB8XxPbZz6TvvKaQ==", + "deprecated": "'native-or-bluebird' is deprecated. Please use 'any-promise' instead." + }, "node_modules/natural-compare": { "version": "1.4.0", "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", @@ -19209,6 +19240,50 @@ "node": ">=4.0.0" } }, + "node_modules/plist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/plist/-/plist-1.2.0.tgz", + "integrity": "sha512-dL9Xc2Aj3YyBnwvCNuHmFl2LWvQacm/HEAsoVwLiuu0POboMChETt5wexpU1P6F6MnibIucXlVsMFFgNUT2IyA==", + "dependencies": { + "base64-js": "0.0.8", + "util-deprecate": "1.0.2", + "xmlbuilder": "4.0.0", + "xmldom": "0.1.x" + } + }, + "node_modules/plist/node_modules/base64-js": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-0.0.8.tgz", + "integrity": "sha512-3XSA2cR/h/73EzlXXdU6YNycmYI7+kicTxks4eJg2g39biHR84slg2+des+p7iHYhbRg/udIS4TD53WabcOUkw==", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/plist/node_modules/lodash": { + "version": "3.10.1", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz", + "integrity": "sha512-9mDDwqVIma6OZX79ZlDACZl8sBm0TEnkf99zV3iMA4GzkIT/9hiqP5mY0HoT1iNLCrKc/R1HByV+yJfRWVJryQ==" + }, + "node_modules/plist/node_modules/xmlbuilder": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-4.0.0.tgz", + "integrity": "sha512-wrG9gc6hCFDd5STt+6fsjP2aGSkjkNSewH+1K6s0KVOd94vXAUyTwlxWVnMFVtLdMf+q0QRZN1z9hTOKgoEdMg==", + "dependencies": { + "lodash": "^3.5.0" + }, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/plist/node_modules/xmldom": { + "version": "0.1.31", + "resolved": "https://registry.npmjs.org/xmldom/-/xmldom-0.1.31.tgz", + "integrity": "sha512-yS2uJflVQs6n+CyjHoaBmVSqIDevTAWrzMmjG1Gc7h1qQ7uVozNhEPJAwZXWyGQ/Gafo3fCwrcaokezLPupVyQ==", + "deprecated": "Deprecated due to CVE-2021-21366 resolved in 0.5.0", + "engines": { + "node": ">=0.1" + } + }, "node_modules/plugin-error": { "version": "1.0.1", "integrity": "sha512-L1zP0dk7vGweZME2i+EeakvUNqSrdiI3F91TwEoYiGrAfUXmVv6fJIq4g82PAXxNsWOp0J7ZqQy/3Szz0ajTxA==", @@ -31520,6 +31595,15 @@ "version": "1.1.4", "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==" }, + "chrome": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/chrome/-/chrome-0.1.0.tgz", + "integrity": "sha512-6KYl20U4Taj6YipylsWr2etUvp9AElJKfGNSBmyGTymYmancnOb041ZNadolEZi2nboLXH7jMSqUmm4kpuTzfg==", + "requires": { + "exeq": "^2.2.0", + "plist": "^1.1.0" + } + }, "chrome-trace-event": { "version": "1.0.3", "integrity": "sha512-p3KULyQg4S7NIHixdwbGX+nFHkoBiA4YQmyWtjb8XngSKV124nJmRysgAeujbUVb15vh+RvFUfCPqU7rXk+hZg==" @@ -33355,6 +33439,15 @@ } } }, + "exeq": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/exeq/-/exeq-2.4.0.tgz", + "integrity": "sha512-B648qbDS00nQZv9UQGLT5RbZm/5dNBX10F8oWeXcgpFHSLm1249u95t/3sn2wXdQjLhlF+edAECdshFtSr1K0Q==", + "requires": { + "bluebird": "^3.0.3", + "native-or-bluebird": "^1.2.0" + } + }, "exit": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", @@ -40933,6 +41026,11 @@ "to-regex": "^3.0.1" } }, + "native-or-bluebird": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/native-or-bluebird/-/native-or-bluebird-1.2.0.tgz", + "integrity": "sha512-0SH8UubxDfe382eYiwmd12qxAbiWGzlGZv6CkMA+DPojWa/Y0oH4hE0lRtFfFgJmPQFyKXeB8XxPbZz6TvvKaQ==" + }, "natural-compare": { "version": "1.4.0", "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", @@ -42245,6 +42343,42 @@ } } }, + "plist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/plist/-/plist-1.2.0.tgz", + "integrity": "sha512-dL9Xc2Aj3YyBnwvCNuHmFl2LWvQacm/HEAsoVwLiuu0POboMChETt5wexpU1P6F6MnibIucXlVsMFFgNUT2IyA==", + "requires": { + "base64-js": "0.0.8", + "util-deprecate": "1.0.2", + "xmlbuilder": "4.0.0", + "xmldom": "0.1.x" + }, + "dependencies": { + "base64-js": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-0.0.8.tgz", + "integrity": "sha512-3XSA2cR/h/73EzlXXdU6YNycmYI7+kicTxks4eJg2g39biHR84slg2+des+p7iHYhbRg/udIS4TD53WabcOUkw==" + }, + "lodash": { + "version": "3.10.1", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz", + "integrity": "sha512-9mDDwqVIma6OZX79ZlDACZl8sBm0TEnkf99zV3iMA4GzkIT/9hiqP5mY0HoT1iNLCrKc/R1HByV+yJfRWVJryQ==" + }, + "xmlbuilder": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-4.0.0.tgz", + "integrity": "sha512-wrG9gc6hCFDd5STt+6fsjP2aGSkjkNSewH+1K6s0KVOd94vXAUyTwlxWVnMFVtLdMf+q0QRZN1z9hTOKgoEdMg==", + "requires": { + "lodash": "^3.5.0" + } + }, + "xmldom": { + "version": "0.1.31", + "resolved": "https://registry.npmjs.org/xmldom/-/xmldom-0.1.31.tgz", + "integrity": "sha512-yS2uJflVQs6n+CyjHoaBmVSqIDevTAWrzMmjG1Gc7h1qQ7uVozNhEPJAwZXWyGQ/Gafo3fCwrcaokezLPupVyQ==" + } + } + }, "plugin-error": { "version": "1.0.1", "integrity": "sha512-L1zP0dk7vGweZME2i+EeakvUNqSrdiI3F91TwEoYiGrAfUXmVv6fJIq4g82PAXxNsWOp0J7ZqQy/3Szz0ajTxA==", diff --git a/package.json b/package.json index ca141fde4..48554d7d0 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "base64url": "^3.0.1", "bcrypt": "^5.0.1", "bmp-js": "^0.1.0", + "chrome": "^0.1.0", "compression": "^1.7.3", "form-data": "^4.0.0", "fs-extra": "^5.0.0", @@ -107,7 +108,7 @@ }, "scripts": { "dbtest": "nodemon -q db/tests.js -w db/tests", - "test:back": "docker compose -f docker-compose.test.yml run --build back npm run test:back:ci", + "test:back": "sh back/runTestBack.sh", "test:back:ci": "node back/tests.js ci", "test:e2e": "node e2e/helpers/tests.js", "test:front": "docker compose -f docker-compose.test.yml up front --build",