Skip to content

Commit

Permalink
Readme and Docker
Browse files Browse the repository at this point in the history
  • Loading branch information
cincarnato committed Jun 26, 2020
1 parent a33b94f commit 7da89bb
Show file tree
Hide file tree
Showing 12 changed files with 85 additions and 17 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
*/node_modules
**/node_modules
14 changes: 5 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
4 changes: 2 additions & 2 deletions apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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",
Expand Down
6 changes: 5 additions & 1 deletion apps/api/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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")})

Expand Down
6 changes: 3 additions & 3 deletions apps/frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Binary file modified apps/frontend/src/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion apps/frontend/src/assets/logo.svg

This file was deleted.

14 changes: 14 additions & 0 deletions docker-compose-development.yml
Original file line number Diff line number Diff line change
@@ -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"
12 changes: 12 additions & 0 deletions docker-compose-production.yml
Original file line number Diff line number Diff line change
@@ -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"
18 changes: 18 additions & 0 deletions readme-docker.md
Original file line number Diff line number Diff line change
@@ -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`
22 changes: 22 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 7da89bb

Please sign in to comment.