diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..ff562d7 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +node_modules +*/node_modules +**/node_modules \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index e3cd361..86ae595 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,23 +4,19 @@ RUN apk add bash RUN npm install pm2 -g -#API -COPY ./apps/api/ /app/api/ - -WORKDIR /app/api +COPY ./apps /apps +#API +WORKDIR /apps/api RUN npm install RUN npm run build #Frontend -COPY ./apps/frontend/ /app/frontend/ -WORKDIR /app/api/dist/frontend +WORKDIR /apps/frontend RUN npm install RUN npm run build - #Start -WORKDIR /app/api/dist -EXPOSE 80 +WORKDIR /apps/api/dist CMD ["pm2-runtime", "start", "index.js"] diff --git a/apps/api/package.json b/apps/api/package.json index 6ee7f2e..ba2b82d 100644 --- a/apps/api/package.json +++ b/apps/api/package.json @@ -4,7 +4,7 @@ "description": "", "main": "src/index.js", "scripts": { - "start": "BABEL_DISABLE_CACHE=1 babel-node src/index.js", + "start": "BABEL_DISABLE_CACHE=1 nodemon src/index.js --exec babel-node -e js", "init": "BABEL_DISABLE_CACHE=1 babel-node src/scripts/init.js", "build": "./node_modules/.bin/babel src -d dist --copy-files && ./node_modules/.bin/babel emails -d dist/emails --copy-files && cp .env dist/.env", "test": "jest" @@ -26,7 +26,7 @@ }, "homepage": "https://github.com/skeleton-metal/apollo-server-express#readme", "dependencies": { - "@ci-user-module/api": "^1.0.41", + "@ci-user-module/api": "^1.0.42", "@ci-custom-module/api": "^1.0.9", "apollo-server-express": "^2.12.0", "axios": "^0.19.2", diff --git a/apps/api/src/index.js b/apps/api/src/index.js index dc0f72a..0e846ec 100644 --- a/apps/api/src/index.js +++ b/apps/api/src/index.js @@ -3,7 +3,7 @@ import express from 'express'; import './mongo-db' import {ApolloServer, GraphQLExtension} from 'apollo-server-express' import {resolvers, typeDefs} from './modules-merge' - +import path from 'path' import {jwtMiddleware, corsMiddleware, rbacMiddleware, sessionMiddleware} from '@ci-user-module/api' import {expressRequestLogger, graphqlErrorLogger, graphqlResponseLogger} from './logger' @@ -52,6 +52,10 @@ app.use('/media/logo', express.static('media/logo')); app.use('/media/export', express.static('media/export')); app.use('/', express.static('web',{index: "index.html"})); +app.get('*', function (request, response) { + response.sendFile(path.resolve(__dirname, 'web/index.html')); +}); + //status app.get('/status', function(req,res){res.send("RUNNING")}) diff --git a/apps/frontend/package-lock.json b/apps/frontend/package-lock.json index 158033b..a1a1f1d 100644 --- a/apps/frontend/package-lock.json +++ b/apps/frontend/package-lock.json @@ -1054,9 +1054,9 @@ } }, "@ci-user-module/frontend": { - "version": "1.0.39", - "resolved": "https://registry.npmjs.org/@ci-user-module/frontend/-/frontend-1.0.39.tgz", - "integrity": "sha512-ZM+DGFs/xro7Ydp4cON3zQ2dGK6165jiP4l5BAeZoncTL+NAsYcZ22nNiF2+6KaGZKaCBCuYdZ8HPD6+2VyxSA==" + "version": "1.0.42", + "resolved": "https://registry.npmjs.org/@ci-user-module/frontend/-/frontend-1.0.42.tgz", + "integrity": "sha512-Q1JKG4Shi1HZ0NfeFaAfY16Z/BQDIIakbIyOfxfhzpQ/v6XigJdfwAv3e+0WUDaVEs1w39KRIldNpsKlzp460Q==" }, "@cnakazawa/watch": { "version": "1.0.4", diff --git a/apps/frontend/package.json b/apps/frontend/package.json index b367b50..eed712f 100644 --- a/apps/frontend/package.json +++ b/apps/frontend/package.json @@ -15,7 +15,7 @@ "apollo-upload-client": "^13.0.0", "chart.js": "^2.9.3", "chartjs-plugin-labels": "^1.1.0", - "@ci-user-module/frontend": "^1.0.39", + "@ci-user-module/frontend": "^1.0.42", "@ci-custom-module/frontend": "^1.0.6", "core-js": "^3.6.5", "graphql": "^15.0.0", diff --git a/apps/frontend/src/assets/logo.png b/apps/frontend/src/assets/logo.png index f3d2503..bd93ff8 100644 Binary files a/apps/frontend/src/assets/logo.png and b/apps/frontend/src/assets/logo.png differ diff --git a/apps/frontend/src/assets/logo.svg b/apps/frontend/src/assets/logo.svg deleted file mode 100644 index 145b6d1..0000000 --- a/apps/frontend/src/assets/logo.svg +++ /dev/null @@ -1 +0,0 @@ -Artboard 46 diff --git a/docker-compose-development.yml b/docker-compose-development.yml new file mode 100644 index 0000000..6d7c8e9 --- /dev/null +++ b/docker-compose-development.yml @@ -0,0 +1,14 @@ +version: "3.5" + +services: + scaffold: + image: cincarnato/ci-scaffold + container_name: ci_scaffold + volumes: + - ./media:/apps/api/dist/media + - ./logs:/apps/api/dist/logs + - ./.env:/apps/api/dist/.env + ports: + - "80:5000" + networks: + - "host" diff --git a/docker-compose-production.yml b/docker-compose-production.yml new file mode 100644 index 0000000..91aa524 --- /dev/null +++ b/docker-compose-production.yml @@ -0,0 +1,12 @@ +version: "3.5" + +services: + scaffold: + image: cincarnato/ci-scaffold + container_name: ci_scaffold + volumes: + - ./media:/apps/api/dist/media + - ./logs:/apps/api/dist/logs + - ./.env:/apps/api/dist/.env + ports: + - "80:5000" diff --git a/readme-docker.md b/readme-docker.md new file mode 100644 index 0000000..7f073a5 --- /dev/null +++ b/readme-docker.md @@ -0,0 +1,18 @@ +## Build Image +* Reemplazar tagname por la version de la imagen (misma version que git) +`docker build -t cincarnato/scaffold:tagname .` + +## PUSH Image + +`docker push cincarnato/scaffold` + +## Docker deploy development with run + +`docker run -it --network="host" -p 8888:5000 cincarnato/scaffold` + +## Docker deploy with compose + +`docker-compose up -d` + +## Stack deploy +`docker stack deploy -c docker-compose.yml stackName` \ No newline at end of file diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..a8b64ee --- /dev/null +++ b/readme.md @@ -0,0 +1,22 @@ +# SPA+GraphQL Scaffold +Base project with SPA frontend and API backend with Grahql + +- Monorepo: Frontend + API Graphql +- Docker ready +- Stateless + +## FRONTEND - SPA + +### Tecnolgies +- HTML, CSS, Javascript +- Vue, Vuex, Vuetify, VueI18n +- GraphqQL with Apollo Client +- JWT Auth + +## Backend - API + +### Tecnolgies +- Javascript / Node +- GraphqQL with Apollo Server +- Mongo with Mongoose +- JWT Auth \ No newline at end of file