WIP: 5739-dockerRefactor #1822

Draft
alexm wants to merge 67 commits from 5739-dockerRefactor into dev
9 changed files with 37 additions and 35 deletions
Showing only changes of commit 07af295730 - Show all commits

View File

@ -20,41 +20,37 @@ RUN apt-get update \
&& apt-get install -y --no-install-recommends \ && apt-get install -y --no-install-recommends \
samba-common-bin samba-dsdb-modules\ samba-common-bin samba-dsdb-modules\
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
# RUN apt update && apt install -y chromium-browser chromium-chromedriver
RUN npm i -g gulp-cli
# RUN npm i -g bun
# RUN apt update && apt install -y chromium-browser chromium-chromedriver
# RUN curl -fsSL https://bun.sh/install | bash # RUN curl -fsSL https://bun.sh/install | bash
# Salix
WORKDIR /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/ 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/ COPY loopback/package.json loopback/
RUN npm install COPY package.json package-lock.json ./
COPY gulpfile.js ./ COPY gulpfile.js ./
COPY \ COPY \
LICENSE \ LICENSE \
README.md \ README.md \
./ ./
# RUN bun --prefix ./print install ./print
FROM base AS local FROM base AS local
WORKDIR /salix
RUN cd ./print && npx puppeteer browsers install chrome
CMD ["npx", "gulp", "backWatch"] CMD ["npx", "gulp", "backWatch"]
FROM base AS test FROM base AS test
WORKDIR /salix
RUN cd ./print && npx puppeteer browsers install chrome
COPY loopback loopback COPY loopback loopback
RUN npm i
COPY back back COPY back back
COPY modules modules COPY modules modules
COPY print print COPY print print
@ -62,4 +58,3 @@ COPY storage storage
# CMD ["npx", "gulp", "backOnly"] # CMD ["npx", "gulp", "backOnly"]
CMD ["npm", "run", "test:back:ci"] CMD ["npm", "run", "test:back:ci"]

View File

@ -1,2 +1,4 @@
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 build --force-rm back db
docker-compose -p salix-test -f docker-compose.test.yml run --rm back docker-compose -p salix-test -f docker-compose.test.yml run --rm back
docker-compose -p salix-test -f docker-compose.test.yml down
docker-compose -p salix-test -f docker-compose.test.yml rm

View File

@ -8,7 +8,7 @@ services:
# volumes: # volumes:
# - .:/salix # - .:/salix
db: db:
image: db image: db:local
restart: unless-stopped restart: unless-stopped
build: build:
context: db context: db
@ -17,6 +17,7 @@ services:
- 3306:3306 - 3306:3306
front: front:
image: front image: front
command: ["npx", "gulp", "front"]
restart: unless-stopped restart: unless-stopped
build: build:
context: . context: .
@ -30,9 +31,11 @@ services:
- ./dist:/salix/dist - ./dist:/salix/dist
- ./front:/salix/front - ./front:/salix/front
- ./loopback:/salix/loopback - ./loopback:/salix/loopback
- ./node_modules:/salix/node_modules
back: back:
image: back image: back
command: ["npx", "gulp", "backWatch"]
restart: unless-stopped restart: unless-stopped
build: build:
context: . context: .
@ -50,8 +53,8 @@ services:
- ./storage:/salix/storage - ./storage:/salix/storage
- ./modules:/salix/modules - ./modules:/salix/modules
- ./back:/salix/back - ./back:/salix/back
# - ./node_modules:/salix/node_modules - ./node_modules:/salix/node_modules
# - ./print:/salix/print - ./print:/salix/print
networks: networks:
salix-stack-network: salix-stack-network:

View File

@ -13,13 +13,15 @@ services:
# volumes: # volumes:
# - ./print:/salix/print # - ./print:/salix/print
db: db:
image: salix-db:test image: db:test
restart: always restart: always
build: build:
context: db context: db
dockerfile: Dockerfile dockerfile: Dockerfile
ports:
- 3306:3306
front: front:
image: salix-front image: front
restart: always restart: always
command: ["npm", "run", "test:front:ci"] command: ["npm", "run", "test:front:ci"]
build: build:
@ -28,7 +30,7 @@ services:
depends_on: depends_on:
- back - back
back: back:
image: salix-back image: back
restart: always restart: always
build: build:
context: . context: .
@ -38,14 +40,8 @@ services:
- NODE_ENV - NODE_ENV
depends_on: depends_on:
- db - db
- node_modules
- print
volumes:
- ./node_modules:/salix/node_modules
- ./print/node_modules:/salix/print/node_modules
networks: networks:
salix-stack-network: stack-network:
driver: host driver: host

View File

@ -1,6 +1,7 @@
FROM back FROM back
EXPOSE 5000 EXPOSE 5000
WORKDIR /salix
COPY /front/gulpfile.js ./ COPY /front/gulpfile.js ./
COPY /front/webpack.config.js ./ COPY /front/webpack.config.js ./
COPY /front/package.json ./front/ COPY /front/package.json ./front/

View File

@ -1,7 +1,8 @@
FROM salix-back FROM back
EXPOSE 5000 EXPOSE 5000
COPY front front COPY front front
RUN npm i -g jest
RUN cd front && npm install --ci RUN cd front && npm install --ci
COPY modules modules COPY modules modules

3
front/runTestFront.sh Normal file
View File

@ -0,0 +1,3 @@
docker-compose -p salix-test -f docker-compose.test.yml run --rm front
docker-compose -p salix-test -f docker-compose.test.yml down
docker-compose -p salix-test -f docker-compose.test.yml rm

View File

@ -1 +1,2 @@
docker run --rm -v $(pwd):/app -w /app node:20-bullseye-slim npm install # 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
docker network create --driver=host salix-stack-network

View File

@ -109,10 +109,10 @@
"scripts": { "scripts": {
"dbtest": "nodemon -q db/tests.js -w db/tests", "dbtest": "nodemon -q db/tests.js -w db/tests",
"test:back": "sh back/runTestBack.sh", "test:back": "sh back/runTestBack.sh",
"test:back:ci": "node back/tests.js ci", "test:back:ci": "sh back/runTestBack.sh",
"test:e2e": "node e2e/helpers/tests.js", "test:e2e": "node e2e/helpers/tests.js",
"test:front": "docker compose -f docker-compose.test.yml up front --build", "test:front": "sh front/runTestFront.sh",
"test:front:ci": "jest --ci --maxWorkers=2", "test:front:ci": "jest --ci --maxWorkers=2",
"back": "nodemon --inspect -w modules ./node_modules/gulp/bin/gulp.js back", "back": "nodemon --inspect -w modules ./node_modules/gulp/bin/gulp.js back",
"lint": "eslint ./ --cache --ignore-pattern .gitignore", "lint": "eslint ./ --cache --ignore-pattern .gitignore",
"docker": "docker build --progress=plain -t salix-db ./db", "docker": "docker build --progress=plain -t salix-db ./db",