Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Hierarchy Folder
- test_dock4
- - db
- - web
- - node_modules
- - Dockerfile
- - index.js
- - package-lock.json
- - package.json
- - docker-compose.yml
- //=================================
- Dockerfile
- FROM node:8.12.0
- # Create app directory
- RUN mkdir /webapp
- WORKDIR /webapp
- # Install app dependencies
- COPY package.json /webapp
- RUN npm install
- # Bundle app source
- COPY . /webapp
- EXPOSE 8080
- CMD ["node", "index.js"]
- //=================================
- docker-compose.yml
- version: '2'
- services:
- web:
- container_name: web
- build: ./web/
- links:
- - db
- environment:
- - DATABASE_URL=postgres://api:123@db:5432/new_databases
- command: node index.js
- ports:
- - "8080:8080"
- volumes:
- - ./web:/webapp
- db:
- image: postgres
- container_name: db
- ports:
- - "5432:5432"
- environment:
- - POSTGRES_USER=api
- - POSTGRES_PASSWORD=123
- - POSTGRES_DATABASE=new_databases
- //=================================
- index.js
- const express = require('express');
- const app = express();
- const pg = require('pg');
- const PORT = 8080;
- app.get('/', (req, res) => {
- res.status(200).json({msg: 'Testing Ok Bos'})
- });
- app.listen(PORT, () => {
- console.log(`Server is listening on port ${PORT}`)
- });
- //=================================
- Error:
- web | Error: Cannot find module '/webapp/index.js'
- web | at Function.Module._resolveFilename (module.js:548:15)
- web | at Function.Module._load (module.js:475:25)
- web | at Function.Module.runMain (module.js:694:10)
- web | at startup (bootstrap_node.js:204:16)
- web | at bootstrap_node.js:625:3
- web exited with code 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement