Skip to content

Docker support #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 89 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
5468eab
[update-manifests] update and add device manifests
aliartiza75 Apr 12, 2020
d564e56
Merge pull request #1 from aliartiza75/update-manifests
aliartiza75 Apr 13, 2020
9802ba1
add-github-actions-support
aliartiza75 Jul 26, 2020
9b07e91
[add-docker-support] add Dockerfile
aliartiza75 Jul 26, 2020
ea99fb4
[add-github-actions-support] fix lint issues
aliartiza75 Jul 26, 2020
207d7b9
[add-github-actions-support] add pipeline statement
aliartiza75 Jul 26, 2020
3c8751f
[add-github-actions-support] add pipeline statement
aliartiza75 Jul 26, 2020
a0c8938
[add-github-actions-support] remove file
aliartiza75 Jul 26, 2020
c285992
[add-github-actions-support] update file
aliartiza75 Jul 26, 2020
c4e9a4f
[add-github-actions-support] update file
aliartiza75 Jul 26, 2020
7322c63
[add-github-actions-support] update file
aliartiza75 Jul 26, 2020
9cd7ca3
Merge pull request #3 from aliartiza75/add-github-actions-support
aliartiza75 Jul 26, 2020
bda9caa
[add-docker-support] fix issues
aliartiza75 Jul 26, 2020
44e897b
[add-docker-support] fix issues
aliartiza75 Jul 26, 2020
186fb6d
[add-docker-support] fix issues
aliartiza75 Jul 26, 2020
14bdf5b
[add-docker-support] fix issues
aliartiza75 Jul 26, 2020
98290eb
[add-docker-support] fix issues
aliartiza75 Jul 26, 2020
4e2628f
[add-docker-support] update Dockerfile and add .dockerignore file
aliartiza75 Jul 26, 2020
28e3854
[add-docker-support] update Dockerfile
aliartiza75 Jul 26, 2020
27c8ab5
[add-docker-support] update package.json
aliartiza75 Jul 26, 2020
16dd33b
[add-docker-support] update package-lock.json
aliartiza75 Jul 26, 2020
3e1e9b1
[add-docker-support] update Dockerfile
aliartiza75 Jul 26, 2020
6abe331
[add-docker-support] update manifests
aliartiza75 Jul 26, 2020
3f340bb
[add-docker-support] update README.md
aliartiza75 Jul 26, 2020
0fcf3db
[add-docker-support] update and add manifests
aliartiza75 Jul 26, 2020
b4bf90a
[add-docker-support] update manifest
aliartiza75 Jul 26, 2020
57c0d4e
[add-docker-support] update manifest
aliartiza75 Jul 26, 2020
1fdf403
[add-docker-support] update app.js
aliartiza75 Aug 26, 2020
401a886
[add-docker-support] update manifest
aliartiza75 Aug 26, 2020
b751968
[add-docker-support] update manifest
aliartiza75 Aug 26, 2020
f5d2ea4
[add-docker-support] update manifest
aliartiza75 Aug 26, 2020
62a4dec
Merge pull request #4 from aliartiza75/add-docker-support
aliartiza75 Aug 26, 2020
dc666b2
Merge pull request #5 from maitraysuthar/master
aliartiza75 Aug 26, 2020
5b3d4cd
Bump express-jwt from 5.3.3 to 6.0.0
dependabot[bot] Jan 7, 2021
c251153
Bump dot-prop from 4.2.0 to 4.2.1
dependabot[bot] Jan 7, 2021
1059e15
Bump ini from 1.3.5 to 1.3.8
dependabot[bot] Jan 7, 2021
5b4b30b
aliartiza75-patch-1
aliartiza75 Jan 7, 2021
0f97907
aliartiza75-patch-1
aliartiza75 Jan 7, 2021
ff0d479
Merge pull request #11 from aliartiza75/aliartiza75-patch-1
aliartiza75 Jan 9, 2021
c88f5dc
Bump y18n from 4.0.0 to 4.0.1
dependabot[bot] Apr 1, 2021
baf41ce
Bump hosted-git-info from 2.8.8 to 2.8.9
dependabot[bot] May 11, 2021
eb3847f
Bump lodash from 4.17.19 to 4.17.21
dependabot[bot] May 11, 2021
4095f12
Bump nodemailer from 6.4.10 to 6.4.16
dependabot[bot] May 12, 2021
513085a
Merge pull request #15 from aliartiza75/dependabot/npm_and_yarn/nodem…
aliartiza75 Jun 3, 2021
a51bf16
Merge pull request #14 from aliartiza75/dependabot/npm_and_yarn/lodas…
aliartiza75 Jun 3, 2021
b2f1e61
Merge pull request #13 from aliartiza75/dependabot/npm_and_yarn/hoste…
aliartiza75 Jun 3, 2021
f034cd3
Merge pull request #12 from aliartiza75/dependabot/npm_and_yarn/y18n-…
aliartiza75 Jun 3, 2021
8005e1e
Merge pull request #9 from aliartiza75/dependabot/npm_and_yarn/ini-1.3.8
aliartiza75 Jun 3, 2021
2546f85
Merge pull request #8 from aliartiza75/dependabot/npm_and_yarn/dot-pr…
aliartiza75 Jun 3, 2021
f9c550e
Merge pull request #7 from aliartiza75/dependabot/npm_and_yarn/expres…
aliartiza75 Jun 3, 2021
5e24bae
Bump bl from 2.2.0 to 2.2.1
dependabot[bot] Jun 3, 2021
93a2033
Merge pull request #6 from aliartiza75/dependabot/npm_and_yarn/bl-2.2.1
aliartiza75 Jun 3, 2021
5a06fa7
add Security.md
aliartiza75 Jun 3, 2021
746da33
[add-docker-support] upgrade packeger version to fix vulnerabilities
aliartiza75 Sep 3, 2021
59e8f02
[add-docker-support] fix conflicts with master
aliartiza75 Sep 3, 2021
b59231b
Merge pull request #19 from aliartiza75/add-docker-support
aliartiza75 Sep 3, 2021
1217c0e
[fix-vulnerabilities] fix issues
aliartiza75 Apr 4, 2022
f342db6
Merge pull request #22 from aliartiza75/fix-vulnerabilities
aliartiza75 Apr 4, 2022
2b7d27c
Bump pathval from 1.1.0 to 1.1.1
dependabot[bot] Apr 4, 2022
575e479
[fix-vulnerabilities] fix issues
aliartiza75 Apr 4, 2022
416bea4
Merge pull request #25 from aliartiza75/fix-vulnerabilities
aliartiza75 Apr 4, 2022
d286aaf
[add-sonarqube] update README.md by adding sonar checks
aliartiza75 Apr 4, 2022
b4ce376
Merge pull request #26 from aliartiza75/add-sonarqube
aliartiza75 Apr 5, 2022
b92c25c
[add-sonarqube] update README.md
aliartiza75 Apr 5, 2022
4087e0b
Merge pull request #27 from aliartiza75/add-sonarqube
aliartiza75 Apr 5, 2022
81cdce5
[add-sonarqube] add quality gates
aliartiza75 Apr 5, 2022
dc2f500
Merge pull request #28 from aliartiza75/add-sonarqube
aliartiza75 Apr 5, 2022
b07f24f
[fix-dependabot-issue] fix dependabot issue
aliartiza75 Apr 12, 2022
208dc69
Merge pull request #30 from aliartiza75/fix-dependabot-issue
aliartiza75 Apr 12, 2022
d88aaad
Bump moment from 2.27.0 to 2.29.2
dependabot[bot] Apr 12, 2022
9c36bcd
Merge pull request #29 from aliartiza75/dependabot/npm_and_yarn/momen…
aliartiza75 Apr 12, 2022
e88b424
Merge pull request #21 from aliartiza75/dependabot/npm_and_yarn/pathv…
aliartiza75 Apr 14, 2022
b3d727b
Merge pull request #10 from aliartiza75/aliartiza75-patch-1-1
aliartiza75 Apr 14, 2022
1e50057
Bump minimatch and mocha
dependabot[bot] Nov 10, 2022
545f5ea
Merge pull request #32 from aliartiza75/dependabot/npm_and_yarn/minim…
aliartiza75 Nov 13, 2022
a076387
Bump moment from 2.29.2 to 2.29.4
dependabot[bot] Nov 13, 2022
53eed14
Bump qs and express
dependabot[bot] Dec 12, 2022
6b4416e
Merge pull request #35 from aliartiza75/dependabot/npm_and_yarn/qs-an…
aliartiza75 Dec 18, 2022
a85e587
Bump got and nodemon
dependabot[bot] Dec 18, 2022
9389124
Merge pull request #36 from aliartiza75/dependabot/npm_and_yarn/got-a…
aliartiza75 Dec 19, 2022
e6e667a
Merge pull request #33 from aliartiza75/dependabot/npm_and_yarn/momen…
aliartiza75 Dec 21, 2022
a245e56
Bump json5 from 2.2.1 to 2.2.3
dependabot[bot] Jan 8, 2023
26649d0
Bump cookiejar from 2.1.2 to 2.1.4
dependabot[bot] Jan 24, 2023
4adf7c8
Merge pull request #39 from aliartiza75/dependabot/npm_and_yarn/cooki…
aliartiza75 Feb 7, 2023
5935257
Merge pull request #38 from aliartiza75/dependabot/npm_and_yarn/json5…
aliartiza75 Feb 12, 2023
a82bbc0
Bump jsonwebtoken from 8.5.1 to 9.0.0
dependabot[bot] Feb 12, 2023
c2d6404
Merge pull request #37 from aliartiza75/dependabot/npm_and_yarn/jsonw…
aliartiza75 Feb 15, 2023
47bfad3
Bump mongoose from 6.2.10 to 6.4.6
dependabot[bot] Feb 15, 2023
27cb8f3
Merge pull request #31 from aliartiza75/dependabot/npm_and_yarn/mongo…
aliartiza75 Feb 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Directories
public
test
.github
build
postman-collection

# Files
.gitignore
.travis.yml
.eslintrc.json
LICENSE
package-lock.json
README.md
CODE_OF_CONDUCT.md
67 changes: 67 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ master ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '30 12 * * 6'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
32 changes: 32 additions & 0 deletions .github/workflows/node.js.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: Node.js CI

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

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [10.x, 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: npm install
- run: cp .env.example .env
- run: source .env
- run: npm run build --if-present
- run: npm run lint --if-present
# - run: npm test --if-present
33 changes: 31 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
[![SonarCloud](https://sonarcloud.io/images/project_badges/sonarcloud-white.svg)](https://sonarcloud.io/summary/new_code?id=aliartiza75_rest-api-nodejs-mongodb)


[![Quality gate](https://sonarcloud.io/api/project_badges/quality_gate?project=aliartiza75_rest-api-nodejs-mongodb)](https://sonarcloud.io/summary/new_code?id=aliartiza75_rest-api-nodejs-mongodb)

[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=aliartiza75_rest-api-nodejs-mongodb&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=aliartiza75_rest-api-nodejs-mongodb)
[![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=aliartiza75_rest-api-nodejs-mongodb&metric=ncloc)](https://sonarcloud.io/summary/new_code?id=aliartiza75_rest-api-nodejs-mongodb)
[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=aliartiza75_rest-api-nodejs-mongodb&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=aliartiza75_rest-api-nodejs-mongodb)
[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=aliartiza75_rest-api-nodejs-mongodb&metric=code_smells)](https://sonarcloud.io/summary/new_code?id=aliartiza75_rest-api-nodejs-mongodb)
[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=aliartiza75_rest-api-nodejs-mongodb&metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=aliartiza75_rest-api-nodejs-mongodb)
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=aliartiza75_rest-api-nodejs-mongodb&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=aliartiza75_rest-api-nodejs-mongodb)
[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=aliartiza75_rest-api-nodejs-mongodb&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=aliartiza75_rest-api-nodejs-mongodb)



# Nodejs Expressjs MongoDB Ready-to-use API Project Structure
[![Author](http://img.shields.io/badge/[email protected])](https://www.linkedin.com/in/maitray-suthar/) [![GitHub license](https://img.shields.io/github/license/maitraysuthar/rest-api-nodejs-mongodb.svg)](https://github.com/maitraysuthar/rest-api-nodejs-mongodb/blob/master/LICENSE) ![GitHub repo size](https://img.shields.io/github/repo-size/maitraysuthar/rest-api-nodejs-mongodb) [![Codacy Badge](https://api.codacy.com/project/badge/Coverage/b3eb80984adc4671988ffb22d6ad83df)](https://www.codacy.com/manual/maitraysuthar/rest-api-nodejs-mongodb?utm_source=github.com&utm_medium=referral&utm_content=maitraysuthar/rest-api-nodejs-mongodb&utm_campaign=Badge_Coverage) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/b3eb80984adc4671988ffb22d6ad83df)](https://www.codacy.com/manual/maitraysuthar/rest-api-nodejs-mongodb?utm_source=github.com&utm_medium=referral&utm_content=maitraysuthar/rest-api-nodejs-mongodb&utm_campaign=Badge_Grade) ![Travis (.com)](https://img.shields.io/travis/com/maitraysuthar/rest-api-nodejs-mongodb)

Expand Down Expand Up @@ -114,7 +129,7 @@ npm install
```
## How to run

### Running API server locally
### Running API server locally

```bash
npm run dev
Expand All @@ -130,6 +145,20 @@ Press CTRL + C to stop the process.
```
**Note:** `YOUR_DB_CONNECTION_STRING` will be your MongoDB connection string.

## Running as Docker container

1. Build its image:

```bash
sudo docker build -t rest-api-nodejs-mongodb:0.0.1 -f build/package/Dockerfile .
```

2. Run it as a container:

```bash
sudo docker run -it -e MONGODB_URL=mongodb://127.0.0.1:27017/rest-api-nodejs-mongodb -e JWT_SECRET=abc1235 -e JWT_TIMEOUT_DURATION="2 hours" --net host api:0.0.1
```

### Creating new models

If you need to add more models to the project just create a new file in `/models/` and use them in the controllers.
Expand Down Expand Up @@ -172,4 +201,4 @@ Every project needs improvements, Feel free to report any bugs or improvements.

## License

This project is open-sourced software licensed under the MIT License. See the LICENSE file for more information.
This project is open-sourced software licensed under the MIT License. See the LICENSE file for more information.
21 changes: 21 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Security Policy

## Supported Versions

Use this section to tell people about which versions of your project are
currently being supported with security updates.

| Version | Supported |
| ------- | ------------------ |
| 5.1.x | :white_check_mark: |
| 5.0.x | :x: |
| 4.0.x | :white_check_mark: |
| < 4.0 | :x: |

## Reporting a Vulnerability

Use this section to tell people how to report a vulnerability.

Tell them where to go, how often they can expect to get an update on a
reported vulnerability, what to expect if the vulnerability is accepted or
declined, etc.
2 changes: 1 addition & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ mongoose.connect(MONGODB_URL, { useNewUrlParser: true, useUnifiedTopology: true
console.error("App starting error:", err.message);
process.exit(1);
});
var db = mongoose.connection;
// var db = mongoose.connection;

var app = express();

Expand Down
10 changes: 10 additions & 0 deletions build/package/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM node:lts
LABEL MAINTAINER Irtiza Ali ([email protected])

COPY . .

RUN npm install

RUN cp .env.example .env

ENTRYPOINT ["npm", "run", "dev"]
10 changes: 10 additions & 0 deletions build/package/Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM node:lts
LABEL MAINTAINER Irtiza Ali ([email protected])

COPY . .

RUN npm install

RUN cp .env.example .env

ENTRYPOINT ["npm", "start"]
Loading