From 280e3c67607bcec46516f6f58193928a5d6a2445 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 16 Jan 2024 15:09:06 +0100 Subject: [PATCH] refs #5739 refactor: front/docker and readme --- README.md | 24 +++++++++++------------- db/reset.sh | 3 +++ db/resetForce.sh | 3 +++ docker-compose.local.yml | 7 ++----- docker-compose.test.yml | 13 ++----------- front/Dockerfile | 34 ++++++++++++++++++++++++++++++++++ front/Dockerfile.local | 10 ---------- front/Dockerfile.test | 21 --------------------- package.json | 3 +-- runTestE2E.sh | 10 ---------- 10 files changed, 56 insertions(+), 72 deletions(-) create mode 100644 db/reset.sh create mode 100644 db/resetForce.sh delete mode 100644 front/Dockerfile.local delete mode 100644 front/Dockerfile.test delete mode 100644 runTestE2E.sh diff --git a/README.md b/README.md index 550e5db73..8e4f865e6 100644 --- a/README.md +++ b/README.md @@ -28,49 +28,47 @@ Pull from repository. $ git clone [url] [directory] ``` + Run this commands on project root directory to install Node dependencies. ```sh $ sh init.sh ``` + Launch application in developer environment. ```sh $ docker compose -f docker-compose.local.yml up -``` -With NodeJS -```sh +# Or with NodeJS $ npm run start ``` -Manually reset fixtures. + +Manually reset fixtures if has changes. ```sh -$ docker compose -f docker-compose.local.yml up --build +$ sh db/reset.sh ``` -With NodeJS +Manually reset strucutre/fixtures always. ```sh -$ npm run restart +$ sh db/resetForce.sh ``` + ## Running the unit tests For client-side unit tests run from project's root. ```sh $ sh runTestFront.sh -``` -With NodeJS -```sh +# Or with NodeJS $ npm run test:front ``` For server-side unit tests run from project's root. ```sh $ sh runTestBack.sh -``` -With NodeJS -```sh +# Or with NodeJS $ npm run test:back ``` diff --git a/db/reset.sh b/db/reset.sh new file mode 100644 index 000000000..76dca9cf5 --- /dev/null +++ b/db/reset.sh @@ -0,0 +1,3 @@ +docker compose -f docker-compose.local.yml down db +docker compose -f docker-compose.local.yml build db +docker compose -f docker-compose.local.yml up db -d diff --git a/db/resetForce.sh b/db/resetForce.sh new file mode 100644 index 000000000..f150ef546 --- /dev/null +++ b/db/resetForce.sh @@ -0,0 +1,3 @@ +docker compose -f docker-compose.local.yml down db +docker compose -f docker-compose.local.yml build db --no-cache +docker compose -f docker-compose.local.yml up db -d diff --git a/docker-compose.local.yml b/docker-compose.local.yml index 776072645..729fbb3d4 100644 --- a/docker-compose.local.yml +++ b/docker-compose.local.yml @@ -21,7 +21,8 @@ services: restart: unless-stopped build: context: . - dockerfile: front/Dockerfile.local + dockerfile: front/Dockerfile + target: local ports: - 5000:5000 depends_on: @@ -55,7 +56,3 @@ services: - ./node_modules:/salix/node_modules - ./print:/salix/print -networks: - salix-stack-network: - driver: host - diff --git a/docker-compose.test.yml b/docker-compose.test.yml index cf4f6556d..ecc4a2312 100644 --- a/docker-compose.test.yml +++ b/docker-compose.test.yml @@ -12,7 +12,8 @@ services: command: ["npx", "jest", "--ci", "--maxWorkers=2"] build: context: . - dockerfile: front/Dockerfile.test + dockerfile: front/Dockerfile + target: test # depends_on: # - back back: @@ -27,13 +28,3 @@ services: - NODE_ENV depends_on: - db - e2e: - image: e2e - restart: always - build: - context: . - dockerfile: e2e/Dockerfile - environment: - - NODE_ENV - depends_on: - - front diff --git a/front/Dockerfile b/front/Dockerfile index d0ee26904..fa088d3d0 100644 --- a/front/Dockerfile +++ b/front/Dockerfile @@ -16,3 +16,37 @@ RUN rm sites-enabled/default && ln -s ../sites-available/salix sites-enabled/sal COPY dist /salix/dist CMD ["nginx", "-g", "daemon off;"] + +FROM back AS local +EXPOSE 5000 + +WORKDIR /salix +COPY /front/gulpfile.js ./ +COPY /front/webpack.config.js ./ +COPY /front/package.json ./front/ +# RUN cd front && npm install --ci + +CMD ["npx", "gulp", "front"] + +FROM back AS test +EXPOSE 5000 +WORKDIR /salix + +COPY front front +# RUN npm i -g jest +RUN cd front && npm install --ci + +COPY modules modules +# COPY dist dist +COPY jest-front.js ./ +COPY jest.front.config.js ./ +COPY babel.config.js ./ +COPY fileMock.js ./ + +COPY /front/gulpfile.js ./ +COPY /front/webpack.config.js ./ +COPY /front/salix ./front/salix +COPY /front/core ./front/core + +CMD ["npx", "gulp", "front"] + diff --git a/front/Dockerfile.local b/front/Dockerfile.local deleted file mode 100644 index 85dd0dacd..000000000 --- a/front/Dockerfile.local +++ /dev/null @@ -1,10 +0,0 @@ -FROM back -EXPOSE 5000 - -WORKDIR /salix -COPY /front/gulpfile.js ./ -COPY /front/webpack.config.js ./ -COPY /front/package.json ./front/ -# RUN cd front && npm install --ci - -CMD ["npx", "gulp", "front"] diff --git a/front/Dockerfile.test b/front/Dockerfile.test deleted file mode 100644 index 89af8f773..000000000 --- a/front/Dockerfile.test +++ /dev/null @@ -1,21 +0,0 @@ -FROM back -EXPOSE 5000 -WORKDIR /salix - -COPY front front -# RUN npm i -g jest -RUN cd front && npm install --ci - -COPY modules modules -# COPY dist dist -COPY jest-front.js ./ -COPY jest.front.config.js ./ -COPY babel.config.js ./ -COPY fileMock.js ./ - -COPY /front/gulpfile.js ./ -COPY /front/webpack.config.js ./ -COPY /front/salix ./front/salix -COPY /front/core ./front/core - -CMD ["npx", "gulp", "front"] diff --git a/package.json b/package.json index 5a8c11d92..663c8c53d 100644 --- a/package.json +++ b/package.json @@ -115,8 +115,7 @@ "back": "nodemon --inspect -w modules ./node_modules/gulp/bin/gulp.js back", "lint": "eslint ./ --cache --ignore-pattern .gitignore", "docker": "docker build --progress=plain -t salix-db ./db", - "start": "docker compose -f docker-compose.local.yml up", - "restart": "docker compose -f docker-compose.local.yml up --build" + "start": "docker compose -f docker-compose.local.yml up" }, "jest": { "projects": [ diff --git a/runTestE2E.sh b/runTestE2E.sh deleted file mode 100644 index 743f51884..000000000 --- a/runTestE2E.sh +++ /dev/null @@ -1,10 +0,0 @@ -docker-compose -p salix-test -f docker-compose.test.yml build --force-rm db -docker-compose -p salix-test -f docker-compose.test.yml build --force-rm back -docker-compose -p salix-test -f docker-compose.test.yml build --force-rm front -docker-compose -p salix-test -f docker-compose.test.yml build --force-rm e2e -docker-compose -p salix-test -f docker-compose.test.yml up db back --no-recreate -docker-compose -p salix-test -f docker-compose.test.yml up front -docker-compose -p salix-test -f docker-compose.test.yml run e2e #--rm -docker-compose -p salix-test -f docker-compose.test.yml rm -s -v -f -# docker-compose -p salix-test -f docker-compose.test.yml down -# docker-compose -p salix-test -f docker-compose.test.yml rm