Skip to content
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

Dockerize server (#249, #236) #251

Merged
merged 40 commits into from
Nov 14, 2019
Merged

Conversation

irsol
Copy link
Collaborator

@irsol irsol commented Oct 26, 2019

Description

App and MongoDB can run as Docker containers.

Issue Addressed

Additionally

Upgraded Node version to 12.0.0.


This change is Reviewable

vinitkumar and others added 30 commits June 11, 2019 11:17
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.11 to 4.17.15.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](lodash/lodash@4.17.11...4.17.15)

Signed-off-by: dependabot[bot] <[email protected]>
…yarn/mixin-deep-1.3.2

Bump mixin-deep from 1.3.1 to 1.3.2
…yarn/lodash-4.17.15

Bump lodash from 4.17.11 to 4.17.15
…yarn/lodash.merge-4.6.2

Bump lodash.merge from 4.6.1 to 4.6.2
…yarn/set-value-2.0.1

Bump set-value from 0.4.3 to 2.0.1
Copy link

@sash-ko sash-ko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 10 of 10 files at r1.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

Copy link

@sash-ko sash-ko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 7 unresolved discussions (waiting on @irsol)


Dockerfile, line 8 at r1 (raw file):

RUN npm install
ENV SECRET='abadjadjadja1223232412424'
ENV developmentDB = 'mongodb://mongodb:27017/ntwitter'

Use capital letter for environment variables, for example, DEVELOPMEN_DB


Dockerfile, line 12 at r1 (raw file):

COPY . .
#Expose port and start application
EXPOSE 3000

Don't change ports if there is not real reason for this


Dockerfile, line 14 at r1 (raw file):

EXPOSE 3000

CMD [ "node", "server.js" ]

node server.js just runs you server. npm start execute start from the scri[ts package.json. In package.json it is defined nodemon server.js. Bear in mind, that nodemon is not needed for Docker it is still needed when running the service without Docker


readme.md, line 54 at r1 (raw file):

};

Usage via Docker

Add here how to run your server in Docker and mongo without (check your config.js)


server.js, line 2 at r1 (raw file):

const express = require('express');
var cookieParser = require('cookie-parser');

See comment about sessions below


server.js, line 15 at r1 (raw file):

const promiseRetry = require('promise-retry');

app.use(cookieParser("super55"));

I think you should not include cookies and sessions into this PR


config/config.js, line 6 at r1 (raw file):

const clientID = process.env.GITHUB_CLIENT_ID;
const clientSecret = process.env.GITHUB_CLIENT_SECRET;
const developmentDB = process.env.developmentDB || 'mongodb://localhost:27017/ntwitter';

See comment about environment variables

Copy link

@sash-ko sash-ko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 8 unresolved discussions (waiting on @irsol)


config/config.js, line 20 at r1 (raw file):

    },
    github: {
      clientID: "e3930cf94c772ba10ef1",

All these secrets should go to .env file ( checkout this blog post Node.js Everywhere with Environment Variables! ). But for this, you need to create another issue and another pull request (just a recommendation)

Copy link

@sash-ko sash-ko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 9 unresolved discussions (waiting on @irsol)


Dockerfile, line 7 at r1 (raw file):

COPY package*.json ./
RUN npm install
ENV SECRET='abadjadjadja1223232412424'

When I run the server without Docker it is missing SECRET variable (see file expess.js where it is used) and I get an error Error: secret option required for sessions. You probably need to define this variable in .env file

Copy link

@sash-ko sash-ko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 10 unresolved discussions (waiting on @irsol)


server.js, line 16 at r1 (raw file):

app.use(cookieParser("super55"));
app.use(cookieSession({

See comment about SECRET how to solve problem that will appear once you remove those lines

@irsol
Copy link
Collaborator Author

irsol commented Nov 5, 2019

Reviewable status: all files reviewed, 10 unresolved discussions (waiting on @irsol)

server.js, line 16 at r1 (raw file):

app.use(cookieParser("super55"));
app.use(cookieSession({

See comment about SECRET how to solve problem that will appear once you remove those lines

Created new issue #252 .

Copy link

@sash-ko sash-ko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 11 unresolved discussions (waiting on @irsol and @sash-ko)


server.js, line 36 at r1 (raw file):

  maxTimeout: 5000
};

Add comments with an explanation why you do this (promiseRetry)

@irsol
Copy link
Collaborator Author

irsol commented Nov 5, 2019

Reviewable status: all files reviewed, 9 unresolved discussions (waiting on @irsol)

Dockerfile, line 7 at r1 (raw file):

COPY package*.json ./
RUN npm install
ENV SECRET='abadjadjadja1223232412424'

When I run the server without Docker it is missing SECRET variable (see file expess.js where it is used) and I get an error Error: secret option required for sessions. You probably need to define this variable in .env file

Created new issue #252 .

@irsol
Copy link
Collaborator Author

irsol commented Nov 6, 2019

environment variable

Renamed env variables.

@vinitkumar
Copy link
Owner

@irsol @sash-ko Sorry guys! I have been busy so I didn't look into the notifications. Posting some comments on the PR. @irsol if you able to resolve this, I will be more than happy to merge this PR.

Copy link
Owner

@vinitkumar vinitkumar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 8 of 11 files reviewed, 12 unresolved discussions (waiting on @irsol and @sash-ko)


Dockerfile, line 12 at r1 (raw file):

Previously, sash-ko (Oleksandr Lysenko) wrote…

Don't change ports if there is not real reason for this

Same. Don't change that port.3000 has always been the port so keep it as it is.


docker-compose.yml, line 6 at r2 (raw file):

    build: .
    ports:
      - "8080:3000"

Keep it as 3000. Don't change it.

@irsol irsol requested a review from vinitkumar November 14, 2019 17:55
@lgtm-com
Copy link

lgtm-com bot commented Nov 14, 2019

This pull request introduces 5 alerts when merging 34b494e into 2e4f8f6 - view on LGTM.com

new alerts:

  • 3 for Hard-coded credentials
  • 2 for Missing CSRF middleware

@vinitkumar vinitkumar changed the base branch from master to develop November 14, 2019 19:41
@lgtm-com
Copy link

lgtm-com bot commented Nov 14, 2019

This pull request introduces 5 alerts when merging 34b494e into c41d553 - view on LGTM.com

new alerts:

  • 3 for Hard-coded credentials
  • 2 for Missing CSRF middleware

@vinitkumar vinitkumar merged commit 34b494e into vinitkumar:develop Nov 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants