Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
pahaz committed Feb 9, 2021
0 parents commit 5908ace
Show file tree
Hide file tree
Showing 249 changed files with 18,051 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
**/.env*
**/.git*
**/__*
**/docker-compose*
**/*.log
**/.DS_Store
**/Dockerfile
**/.dockerignore
**/node_modules
**/.next
**/dist
**/out
**/.idea
**/.kmigrator
**/docs
**/.config
**/.yarn
**/.cache
18 changes: 18 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#DATABASE_URL=mongodb://mongo:mongo@127.0.0.1/main?authSource=admin
DATABASE_URL=postgresql://postgres:postgres@127.0.0.1/main
NODE_ENV=development
DISABLE_LOGGING=true
COOKIE_SECRET=random
SERVER_URL=http://localhost:3000

# production docker deploy envs!
DOCKER_FILE_INSTALL_COMMAND="python3 -m pip install 'psycopg2-binary>=2.8.5' && python3 -m pip install 'Django>=3.0.6'"
DOCKER_FILE_BUILD_COMMAND=yarn workspace @app/demo build
DOCKER_COMPOSE_APP_IMAGE_TAG=demo
DOCKER_COMPOSE_START_APP_COMMAND=yarn workspace @app/demo start
#DOCKER_COMPOSE_DATABASE_URL=mongodb://mongo:mongo@mongodb/main?authSource=admin
DOCKER_COMPOSE_DATABASE_URL=postgresql://postgres:postgres@postgresdb/main
DOCKER_COMPOSE_COOKIE_SECRET=random
# change it -------------------^
DOCKER_COMPOSE_SERVER_URL=https://demo.dok.8iq.dev
# change it -------------------^
14 changes: 14 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apps/sberhack

# Ignore artifacts
**/.next
**/node_modules
**/out
**/__generated__

# Ignore test files
**/test*

# Ignore other files
package.json
README.md
53 changes: 53 additions & 0 deletions .github/workflows/nodejs.apps.demo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: RUN DEMO TESTS

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x, 14.x]
database: ["postgresql://postgres:postgres@127.0.0.1/main", "mongodb://mongo:mongo@127.0.0.1/main?authSource=admin"]

steps:
- uses: actions/checkout@v2
- name: Prepare .env
run: cp .env.example .env
- name: Docker compose up databases
run: docker-compose up -d mongodb postgresdb
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: install packages
run: |
yarn
pip3 install django
pip3 install psycopg2-binary
- name: run tests for ${{ matrix.database }}
run: |
set -x
# export DEBUG=knex:query,knex:tx
# export DEBUG_MONGOOSE=1
[[ $DATABASE_URL == postgresql* ]] && yarn workspace @app/demo migrate
yarn workspace @app/demo dev &
# Wait until server is up!
while ! [[ $(curl -s 'http://localhost:3000/admin/api' --data-raw '{"operationName":null,"variables":{},"query":"{appVersion}"}' -H 'content-type: application/json') == *"appVersion"* ]]; do
sleep 0.5
done
sleep 1
yarn workspace @app/demo test
env:
DATABASE_URL: ${{ matrix.database }}
NODE_ENV: development
DISABLE_LOGGING: true
32 changes: 32 additions & 0 deletions .github/workflows/nodejs.apps.front.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: TEST FRONT APPS

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x, 14.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: yarn
- name: Show all node_modules dirs
run: find . -name "node_modules" -type d -prune | xargs ls -lah
- run: yarn run jest ./packages
- run: yarn workspace @app/ex01front test
- run: yarn workspace @app/ex02front test
25 changes: 25 additions & 0 deletions .github/workflows/nodejs.codestyle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: LINTER

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x]

steps:
- uses: actions/checkout@v2
- name: Check lint with eslint
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: yarn
- run: yarn lint
44 changes: 44 additions & 0 deletions .github/workflows/nodejs.demo.deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: DEPLOY DEMO

on:
push:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_DOCK_SERVER_PRIVATE_KEY }}
name: id_rsa
known_hosts: ${{ secrets.SSH_DOCK_SERVER_KNOWN_HOSTS }}
- name: Prepare
run: |
cp .env.example .env
sudo apt install -y pv
ssh root@dok.8iq.dev 'id'
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_DOCK_SERVER_PRIVATE_KEY }}
- name: Docker build
run: |
bash ./bin/warm-docker-cache
docker-compose build
- name: Upload builded image
run: |
ssh root@dok.8iq.dev "docker rmi apps:demo || echo no image"
docker save apps:demo | bzip2 | pv | ssh root@dok.8iq.dev 'bunzip2 | docker load'
- name: Restart demo app
run: |
export APP_VERSION=$GITHUB_SHA
export APP=demo
ssh root@dok.8iq.dev "docker tag apps:${APP} dokku/${APP}:${APP_VERSION}"
ssh root@dok.8iq.dev "dokku tags:deploy ${APP} ${APP_VERSION}"
ssh root@dok.8iq.dev "docker exec -i -u root ${APP}.web.1 yarn workspace @app/${APP} migrate"
28 changes: 28 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
node_modules
dist
out
.next
.idea
.env
.kmigrator
.DS_Store
.docker-cache-warming
.expo
.expo-shared
web-build
__generated__
__media
_example.js

# yarn + npm
yarn-error.log
yarn.lock
npm-debug.*

# mobile
*.jks
*.p8
*.p12
*.key
*.mobileprovision
*.orig.*
57 changes: 57 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
FROM buildpack-deps:buster AS base
# https://hub.docker.com/_/node
# https://github.com/nodejs/docker-node/blob/18ed56ea9ba03c16f48372927f5eb2553033e8de/14/buster/Dockerfile
# https://hub.docker.com/_/python
# https://github.com/docker-library/python/blob/f59139d685b3b39d4452a686521e03fa093efa25/3.8/buster/Dockerfile
COPY --from=python:buster /usr/local/ /usr/local/
COPY --from=node:buster /usr/local/ /usr/local/
COPY --from=node:buster /opt/ /opt/
# http://bugs.python.org/issue19846
# > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK.
ENV LANG C.UTF-8
# Add app user/group! Clean packages and fix links! Check version! And install some extra packages!
ARG DOCKER_FILE_INSTALL_COMMAND
ENV DOCKER_FILE_INSTALL_COMMAND ${DOCKER_FILE_INSTALL_COMMAND}
RUN set -ex \
&& groupadd -r app --gid=999 \
&& useradd --system --create-home --home /home/app --gid 999 --uid=999 --shell /bin/bash app \
&& ldconfig -v \
&& find /usr/local -depth \
\( \
\( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \
-o \
\( -type f -a \( -name '*.pyc' -o -name '*.pyo' \) \) \
\) -exec rm -rf '{}' + \
&& rm -f /usr/local/bin/docker-entrypoint.sh \
&& python --version \
&& pip --version \
&& node --version \
&& npm --version \
&& yarn --version \
&& bash -c "${DOCKER_FILE_INSTALL_COMMAND:?Build argument DOCKER_FILE_INSTALL_COMMAND needs to be set (check READEME.md)!}" \
&& echo "OK"

# Build container
FROM base AS build
ARG DOCKER_FILE_BUILD_COMMAND
ENV DOCKER_FILE_BUILD_COMMAND ${DOCKER_FILE_BUILD_COMMAND}
USER app:app
WORKDIR /home/app
RUN echo "# Build time .env config!" >> /home/app/.env && \
echo "COOKIE_SECRET=undefined" >> /home/app/.env && \
echo "DATABASE_URL=undefined" >> /home/app/.env && \
echo "NODE_ENV=production" >> /home/app/.env
# If you don't have this directory, you can create it by command `bash ./bin/warm-docker-cache` or just create empty ./.docker-cache-warming dir (no cache mode)
ADD --chown=app:app ./.docker-cache-warming /home/app
# Cache packages!
RUN set -ex && yarn install
ADD --chown=app:app . /home/app
RUN set -ex && yarn && bash -c "${DOCKER_FILE_BUILD_COMMAND:?Build argument DOCKER_FILE_BUILD_COMMAND needs to be set (check READEME.md)!}" && \
yarn cache clean && rm -rf /home/app/.env && rm -rf /home/app/.config && rm -rf /home/app/.yarn && rm -rf /home/app/.cache && \
ls -lah /home/app/

# Runtime container
FROM base
USER app:app
WORKDIR /home/app
COPY --from=build --chown=root:root /home/app /home/app
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 8IQ Software Company

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
69 changes: 69 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
[![Hackathon workflow](https://image.shutterstock.com/image-vector/banner-hackathon-design-sprintlike-event-260nw-1418226719.jpg)](https://drive.google.com/drive/folders/1Srw2T91_rRLTWgJc-Zh693hhbD2JS6Yh)

[![Look At Screenshot folder!](https://user-images.githubusercontent.com/1394025/105494912-4cbe4d80-5cdd-11eb-8148-4940c0ce7846.png)](https://drive.google.com/drive/folders/1Srw2T91_rRLTWgJc-Zh693hhbD2JS6Yh)

# Rapid Development Node.js Hackathon template: [DEMO](https://demo.dok.8iq.dev/)

This template based on [KeystoneJS](https://github.com/keystonejs/keystone) and [Next.js](https://github.com/vercel/next.js).

We also use [Expo](https://github.com/expo/expo) for React based mobile app development.
[Ant Design](https://github.com/ant-design/ant-design) as React Web UI kit and [UI Kitten](https://github.com/akveo/react-native-ui-kitten) as React Native UI kit

KeystoneJS is just a glue between [Express](https://github.com/expressjs/express),
[ApolloGraphql](https://github.com/apollographql/), Mongoose/Knex/Prisma (as ORM).

Next.js is just a zero config React based framework.

### Contents

* [Motivation & Features](#why)
* [Getting started](docs/getting-started.md)
* [Deploy](docs/deploy.md)
* [Contibuting](docs/contributing.md)

## Why?

Javascript ecosystem is full of tutorials, open-source and helpful materials,
but still, it's often **up to the developer** to implement such **basic** features like:
* Authentication workflow (register-login-reset)
* Permission mechanism
* Import/Export
* Logic reusability between web and mobile
* And more

This project provides you with these basic features, allowing you to focus on core business logic

Our primary focus is startup developers and hackaton teams

## Features

**VERSION**: 0.0.1 **𝛼**

* Based on ApolloGraphql, KeystoneJS and NextJS
* Auth flow
* Registration
* Authentication and Authorization
* Change password
* Reset password
* Organization entity
* Management of organization members
* Invite users
* Import users from excel
* Ant design based frontend
* A lot of examples — check /apps
* Pluggable — use only what you need
* Deployable — check [deploy.md](docs/deploy.md)

Full list of features and requested features is found under [contibuting.md](docs/contributing.md) and issues

## Getting started

Check [getting-started.md](docs/getting-started.md)

## Deploying

Check [deploy.md](docs/deploy.md)

## Contributing

Check [contributing.md](docs/contributing.md)
5 changes: 5 additions & 0 deletions apps/_demo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# demo #

This project is deployed on demo.dok.8iq.dev!

We use it for e2e purposes! Please don't use it as example!
Loading

0 comments on commit 5908ace

Please sign in to comment.