Working on the dev environment
9 files+921−530/9 viewed
| 1 | − | **/.classpath | |
| 2 | − | **/.dockerignore | |
| 3 | − | **/.env | |
| 4 | − | **/.git | |
| 5 | − | **/.gitignore | |
| 6 | − | **/.project | |
| 7 | − | **/.settings | |
| 8 | − | **/.toolstarget | |
| 9 | − | **/.vs | |
| 10 | − | **/.vscode | |
| 11 | − | **/*.*proj.user | |
| 12 | − | **/*.dbmdl | |
| 13 | − | **/*.jfm | |
| 14 | − | **/azds.yaml | |
| 15 | − | **/charts | |
| 16 | − | **/docker-compose* | |
| 17 | − | **/compose* | |
| 18 | − | **/Dockerfile* | |
| 19 | − | **/node_modules | |
| 20 | − | **/npm-debug.log | |
| 21 | − | **/obj | |
| 22 | − | **/secrets.dev.yaml | |
| 23 | − | **/values.dev.yaml | |
| 24 | − | README.md | |
| 1 | + | node_modules | |
| 2 | + | npm-debug.log | |
| 3 | + | .git |
| 1 | − | FROM node:14-alpine | |
| 1 | + | # https://blog.logrocket.com/node-js-docker-improve-dx/ | |
| 2 | + | FROM node:14-alpine as base | |
| 3 | + | ||
| 4 | + | WORKDIR /src | |
| 5 | + | COPY package*.json / | |
| 6 | + | EXPOSE 3000 | |
| 7 | + | ||
| 8 | + | FROM base as production | |
| 2 | 9 | ENV NODE_ENV=production | |
| 3 | − | WORKDIR /usr/src/app | |
| 4 | − | COPY ["package.json", "package-lock.json*", "npm-shrinkwrap.json*", "./"] | |
| 5 | − | RUN npm install --production --silent && mv node_modules ../ | |
| 6 | − | COPY . . | |
| 7 | − | EXPOSE 3000 | |
| 8 | − | CMD ["npm", "start"] | |
| 10 | + | RUN npm ci | |
| 11 | + | COPY . / | |
| 12 | + | CMD ["node", "bin/www"] | |
| 13 | + | ||
| 14 | + | FROM base as dev | |
| 15 | + | ENV NODE_ENV=development | |
| 16 | + | RUN npm install -g nodemon && npm install | |
| 17 | + | COPY . / | |
| 18 | + | CMD ["nodemon", "bin/www"] |
| 1 | − | version: '3.4' | |
| 2 | − | ||
| 3 | − | services: | |
| 4 | − | todoapp: | |
| 5 | − | image: todoapp | |
| 6 | − | build: | |
| 7 | − | context: . | |
| 8 | − | dockerfile: ./Dockerfile | |
| 9 | − | environment: | |
| 10 | − | NODE_ENV: development | |
| 11 | − | ports: | |
| 12 | − | - 3000:3000 | |
| 13 | − | - 9229:9229 | |
| 14 | − | command: ["node", "--inspect=0.0.0.0:9229", "./bin/www"] |
| 1 | − | version: '3.4' | |
| 1 | + | version: '3.8' | |
| 2 | 2 | ||
| 3 | 3 | services: | |
| 4 | 4 | todoapp: | |
| 5 | 5 | image: todoapp | |
| 6 | 6 | build: | |
| 7 | − | context: . | |
| 8 | − | dockerfile: ./Dockerfile | |
| 7 | + | context: ./ | |
| 8 | + | target: dev | |
| 9 | + | volumes: | |
| 10 | + | - .:/src | |
| 11 | + | command: "npm run start:dev" | |
| 9 | 12 | environment: | |
| 10 | − | NODE_ENV: production | |
| 13 | + | NODE_ENV: development | |
| 14 | + | DEBUG: nodejs-docker-express:* | |
| 11 | 15 | ports: | |
| 12 | 16 | - 3000:3000 |
A large diff (1,115 lines) is not shown until you ask for it.
| 3 | 3 | "version": "0.0.0", | |
| 4 | 4 | "private": true, | |
| 5 | 5 | "scripts": { | |
| 6 | − | "start": "node ./bin/www" | |
| 6 | + | "start": "node ./bin/www", | |
| 7 | + | "start:dev": "nodemon ./bin/www" | |
| 7 | 8 | }, | |
| 8 | 9 | "dependencies": { | |
| 9 | 10 | "cookie-parser": "~1.4.4", | |
| ⋯ | |||
| 11 | 12 | "express": "~4.16.1", | |
| 12 | 13 | "http-errors": "~1.6.3", | |
| 13 | 14 | "jade": "~1.11.0", | |
| 14 | − | "morgan": "~1.9.1" | |
| 15 | + | "morgan": "~1.9.1", | |
| 16 | + | "nodemon": "^2.0.12", | |
| 17 | + | "vue": "^2.6.14" | |
| 15 | 18 | } | |
| 16 | 19 | } | |
| 1 | + | var app = new Vue({ | |
| 2 | + | el: '#app', | |
| 3 | + | data: { | |
| 4 | + | message: 'Hello Vue!' | |
| 5 | + | } | |
| 6 | + | }) |
| 2 | 2 | var router = express.Router(); | |
| 3 | 3 | ||
| 4 | 4 | /* GET home page. */ | |
| 5 | − | router.get('/', function(req, res, next) { | |
| 6 | − | res.render('index', { title: 'Express' }); | |
| 5 | + | // router.get('/', function(req, res, next) { | |
| 6 | + | // res.render('index', { title: 'Express' }); | |
| 7 | + | // }); | |
| 8 | + | ||
| 9 | + | router.get('/', function(req, res) { | |
| 10 | + | res.send('Some data here 3'); | |
| 7 | 11 | }); | |
| 8 | 12 | ||
| 9 | 13 | module.exports = router; |
| 1 | + | <!doctype html> | |
| 2 | + | <html> | |
| 3 | + | <head> | |
| 4 | + | <title>This is the title of the webpage!</title> | |
| 5 | + | <!-- development version, includes helpful console warnings --> | |
| 6 | + | <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script> | |
| 7 | + | </head> | |
| 8 | + | <body> | |
| 9 | + | <p>This is an example paragraph. Anything in the <strong>body</strong> tag will appear on the page, just like this <strong>p</strong> tag and its contents.</p> | |
| 10 | + | ||
| 11 | + | <div id="app"> | |
| 12 | + | {{ message }} | |
| 13 | + | </div> | |
| 14 | + | ||
| 15 | + | <script src="/public/javascripts/index.js"></script> | |
| 16 | + | ||
| 17 | + | </body> | |
| 18 | + | ||
| 19 | + | </html> |
Comments
Sign in to comment.