diff --git a/Dockerfile b/Dockerfile index d0b94f820..a6f0f056d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,24 @@ -FROM node:stretch-slim +FROM node:20-bullseye as base + +FROM base AS production RUN npm install -g @quasar/cli WORKDIR /app COPY dist/spa ./ -CMD ["quasar", "serve", "./", "--history", "--hostname", "0.0.0.0"] \ No newline at end of file +CMD ["quasar", "serve", "./", "--history", "--hostname", "0.0.0.0"] + +FROM base AS test +WORKDIR /app +COPY package.json package-lock.json ./ +COPY src src +COPY test test +COPY quasar quasar + +RUN npm i + +CMD ["npx", "quasar", "dev"] + +FROM base AS local +WORKDIR /app +CMD ["npx", "quasar", "dev"] + + diff --git a/docker-compose.local.yml b/docker-compose.local.yml new file mode 100644 index 000000000..13ed22351 --- /dev/null +++ b/docker-compose.local.yml @@ -0,0 +1,16 @@ +version: '3.7' +services: + lilium: + image: lilium-front + restart: always + build: + context: . + dockerfile: Dockerfile + target: local + ports: + - 9000:9000 + volumes: + - .:/app +networks: + salix-stack-network: + driver: host diff --git a/docker-compose.test.yml b/docker-compose.test.yml new file mode 100644 index 000000000..a6ff18ba1 --- /dev/null +++ b/docker-compose.test.yml @@ -0,0 +1,10 @@ +version: '3.7' +services: + lilium: + image: lilium-front + restart: always + command: ['npm', 'run', 'test:unit:ci'] + build: + context: . + dockerfile: Dockerfile + target: test diff --git a/docker-compose.yml b/docker-compose.yml index 6494739f2..b1dc1508c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,17 +1,17 @@ version: '3.7' services: - main: - image: registry.verdnatura.es/salix-frontend:${BRANCH_NAME:?} - build: - context: . - dockerfile: ./Dockerfile - ports: - - 4000 - deploy: - replicas: ${FRONT_REPLICAS:?} - placement: - constraints: - - node.role == worker - resources: - limits: - memory: 1G + main: + image: registry.verdnatura.es/salix-frontend:${BRANCH_NAME:?} + build: + context: . + dockerfile: ./Dockerfile + ports: + - 4000 + deploy: + replicas: ${FRONT_REPLICAS:?} + placement: + constraints: + - node.role == worker + resources: + limits: + memory: 1G diff --git a/package.json b/package.json index c4f5b828a..a9b133830 100644 --- a/package.json +++ b/package.json @@ -7,12 +7,14 @@ "private": true, "scripts": { "lint": "eslint --ext .js,.vue ./", + "start": "docker compose -p salix -f docker-compose.local.yml up", + "restart": "docker compose -p salix -f docker-compose.local.yml up --build", "format": "prettier --write \"**/*.{js,vue,scss,html,md,json}\" --ignore-path .gitignore", "test:e2e": "cypress open", "test:e2e:ci": "cd ../salix && gulp docker && cd ../salix-front && cypress run", "test": "echo \"See package.json => scripts for available tests.\" && exit 0", "test:unit": "vitest", - "test:unit:ci": "vitest run" + "test:unit:ci": "docker-compose -f docker-compose.test.yml run --rm lilium" }, "dependencies": { "@quasar/cli": "^2.3.0", diff --git a/quasar.config.js b/quasar.config.js index 755e96bd3..e75f28d67 100644 --- a/quasar.config.js +++ b/quasar.config.js @@ -67,7 +67,7 @@ module.exports = configure(function (/* ctx */) { // analyze: true, // env: {}, rawDefine: { - 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV) + 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV), }, // ignorePublicFolder: true, // minify: false, @@ -92,7 +92,7 @@ module.exports = configure(function (/* ctx */) { vitePlugins: [ [ VueI18nPlugin({ - runtimeOnly: false + runtimeOnly: false, }), { // if you want to use Vue I18n Legacy API, you need to set `compositionOnly: false` @@ -111,7 +111,7 @@ module.exports = configure(function (/* ctx */) { }, proxy: { '/api': { - target: 'http://0.0.0.0:3000', + target: 'http://back:3000', logLevel: 'debug', changeOrigin: true, secure: false,