Node js sample app with inversify
and graphql(using apollo graphql)
.
It includes winston
for logging and stoppable
for graceful shutdowns.
Can be used with or without docker. Instructions are written below.
- Clone the repo and
cd
into it.
- Run
npm i
- create
.env
file to the root of this folder and copy contents fromexample.env
into it. - Run
npm run dev
to run server with nodemon.
To run compiled code, run
npm run build
, provide environment variables(.env file will not be read with compiled code) and thennpm start
a. For building dev stage
- create
.env
file to the root of this folder and copy contents fromexample.env
into it. - Run
docker-compose build
- Run
docker-compose up
b. For building prod stage
- For environment variables, create
.env
file to the root of this folder and copy contents fromexample.env
into it. OR use some other way of providing environment variables to the compose file.
Note: the above method is only used for this example. More secure way must be used for passing environment variables to the docker container. See the comment in
dockerfile
inprod
stage section
- Run
docker-compose -f docker-compose.yml build
- Run
docker-compose -f docker-compose.yml up
You are ready to build exciting things upon this sample app.