Skip to content

Add docker support #18

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 54 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 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
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
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
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ npm install
```
## How to run

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

```bash
npm run dev
Expand All @@ -130,6 +130,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
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