Coder Social home page Coder Social logo

iamgrewal7 / node.js-graphql-docker-nginx-template Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 629 KB

A starter code for Nodejs, GraphQL, Docker and more

Dockerfile 2.71% Shell 5.23% TypeScript 92.06%
nodejs graphql-yoga apollo-server graphql docker nginx redis typescript mysql prisma cerbot github-actions

node.js-graphql-docker-nginx-template's Introduction

Overview

The project is build using docker, with different configuration for development and production and environment. Language used is TypeScipt (config and lint file is include). I am using GraphQL-yoga which is build on top of Apollo, Express server. Redis is used along with express-session for maintain session. Project also consist of winston logger which logs all the errors to error.log file and Sentry library if you wish to track errors on sentry For persistance, I use MySQL along with Prisma ORM which can automatically apply migrations and has nice Django-Admin like UI for adding and dropping data.

How to get started

Development

  1. Install Docker Cli and Docker Compose
  2. Clone the repo and create a .env file with following info
    • SECRET_KEY(Used by Redis)
    • NODE_ENV
    • HOST
    • PORT
    • SESSION_NAME
  3. docker-compose -f "docker-compose.dev.yml" -f "docker-compose.yml" up -d --build
  4. This will build images for Node, MySQL, Redis and Express Server and will run those images in seperate containers.
  5. Open shell for MySQL container using docker exec -it {continer_id or name} /bin/sh -c "[ -e /bin/bash ] && /bin/bash || /bin/sh" and create database.
  6. "docker-compose.dev.yml" run the express server using nodemon and mounts the local volume, therfore any edit made in project folder, will trigger nodemon to rebuild the server and therefore enabling development while in docker.

Production

  1. For deploying the project use docker-compose.prod.yml file instead of "docker-compose.dev.yml". It creates and run image of NGINX(used as reverse proxy) and Certbot(used for ssl certificate for domains)
  2. You will still need to create databse inside docker, when running this for first time.

WIP

node.js-graphql-docker-nginx-template's People

Contributors

iamgrewal7 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.