WIP: 5739-dockerRefactor #1822

Draft
alexm wants to merge 67 commits from 5739-dockerRefactor into dev
10 changed files with 203 additions and 26 deletions
Showing only changes of commit bd062adf2a - Show all commits

View File

@ -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"]

View File

@ -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"]

2
back/runTestBack.sh Normal file
View File

@ -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

View File

@ -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:

View File

@ -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:

View File

@ -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"]

View File

@ -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"

1
init.sh Normal file
View File

@ -0,0 +1 @@
docker run --rm -v $(pwd):/app -w /app node:20-bullseye-slim npm install
Review

Genera los node_modules sin tener node instalado

Genera los node_modules sin tener node instalado

134
package-lock.json generated
View File

@ -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==",

View File

@ -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",