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

Dockerized version of the application #66

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .browser-refresh-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/public/vendor
/public/images
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v12.18.4
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM node:12.18.4-alpine

LABEL maintainer="[email protected] || [email protected]"
LABEL author="Roger Kondrat"

RUN mkdir -p /src/app/node_modules && chown -R node:node /src/app
WORKDIR /src/app


COPY package*.json ./
RUN npm install --silent

Choose a reason for hiding this comment

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

I'd run npm ci here instead; it'll install exactly the versions used in package-lock.json.

Copy link
Author

Choose a reason for hiding this comment

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

That's a great point Emile.


COPY . ./

Choose a reason for hiding this comment

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

The way I usually do this step is by individually copying the relevant top-level files or directories. In this case, it'll probably cause problems if the student did an "npm install" before building the image.

Copy link
Author

Choose a reason for hiding this comment

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

Can you give me a more specific suggestion?

Choose a reason for hiding this comment

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

I think we only need public and server in this case, so I'd do:

COPY ./public ./public
COPY ./server ./server


ENV PORT=5000

EXPOSE 5000

CMD [ "npm", "run", "local" ]
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,21 @@

Tweeter is a simple, single-page Twitter clone.

This repository is the starter code for the project: Students will fork and clone this repository, then build upon it to practice their HTML, CSS, JS, jQuery and AJAX front-end skills, and their Node, Express and MongoDB back-end skills.
This repository is the starter code for the project: Students will fork and clone this repository, then build upon it to practice their HTML, CSS, JS, jQuery and AJAX front-end skills.

## Getting Started

1. Fork this repository, then clone your fork of this repository.
2. Install dependencies using the `npm install` command.
3. Start the web server using the `npm run local` command. The app will be served at <http://localhost:8080/>.
4. Go to <http://localhost:8080/> in your browser.
2. *FIRST TIME ONLY!* Run the following command `npm docker:init`.
3. Start web server using the `npm run docker:start` command. The app will be served at <http://localhost:3000/>.
4. Go to <http://localhost:3000/> in your browser.
5. *COMPLETION OF PROJECT* Once the project has been accepted you should run `npm run docker:destroy` command.

## Dependencies
## Notes for general project operation (optional extras)
* End of the day command `npm run docker:halt`. This will shutdown, but not destroy the files necessary to run your project.
* Morning; restarting work on your project `npm run docker:start`

- Express
- Node 5.10.x or above
## Requirements
- Internet Connection
- Docker
- Text Editor (VS Code recommended)
15 changes: 15 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: '3.8'

services:
node-express:
image: rogerkondrat/tweeter
container_name: tweeter
build:
context: ./
dockerfile: Dockerfile
ports:
- "5000:5000"
- "3000:3000"

Choose a reason for hiding this comment

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

Why port 3000?

Copy link
Author

Choose a reason for hiding this comment

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

Quoted from above: Like all things weird I had a problem once and it was a while ago and it fixed it. Sometimes when I copy and paste across most of my existing processes I forget to delete something. Thanks for pointing this out.

Also I just wrote this quickly. I never thought it would go to production as is, so no judging please ;)
Consider this just a quick and dirty draft that I put out there and I'm happy to update it and make it final after I hear there is appetite for this kind of change to our way of doing things.

Choose a reason for hiding this comment

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

No problem! That's why we do code reviews ;)

volumes:
- .:/src/app
- /src/app/node_modules

Choose a reason for hiding this comment

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

Not sure why you make node_modules a volume?

Copy link
Author

Choose a reason for hiding this comment

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

Like all things weird I had a problem once and it was a while ago and it fixed it. Sometimes when I copy and paste across most of my existing processes I forget to delete something. Thanks for pointing this out.

Loading