From 41ee19c26f658aeda3ab45f9d977de76904ef10b Mon Sep 17 00:00:00 2001 From: bigansh_ Date: Tue, 15 Jun 2021 15:21:40 +0530 Subject: [PATCH] add .dockerignore & change compose --- .dockerignore | 6 ++++++ Dockerfile | 4 +++- app.js | 2 +- docker-compose.yml | 28 ++++++++++++++++++++++------ 4 files changed, 32 insertions(+), 8 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..e79f0c6 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +#Folders +.git +/node_modules + +#Files +.env \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 103546e..400feb2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,6 @@ FROM node:alpine -COPY . /app WORKDIR /app +COPY package.json /app +RUN npm install +COPY . /app CMD npm start \ No newline at end of file diff --git a/app.js b/app.js index 8397344..5b5ab3e 100644 --- a/app.js +++ b/app.js @@ -34,6 +34,6 @@ app.get('robots.txt', (req, res) => { res.sendFile('robots.txt', { root: __dirname }) }) -app.listen(process.env.PORT, () => { +app.listen(process.env.PORT || 3000, () => { console.log('Connected') }) diff --git a/docker-compose.yml b/docker-compose.yml index 231d181..372d2ea 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,22 @@ -version: 1.0 -services: - web: - build: . - ports: - - "9000":"3000" +version: '3.0' +services: + app: + container_name: tvmultiverse28 + build: . + ports: + - '9000:3000' + env_file: .env + links: + - mongo + networks: + - app-network + mongo: + container_name: mongo + image: mongo + ports: + - '27017:27017' +networks: + app-network: + driver: bridge +volumes: + dbdata: