1
0
Fork 0
mirror of https://github.com/docker/awesome-compose.git synced 2025-04-25 10:18:07 +02:00

nodejs postgres connection

Signed-off-by: Utkarsh Mathur <utkarshmathur05@gmail.com>
This commit is contained in:
Utkarsh Mathur 2023-02-03 02:08:41 +05:30
parent e6b1d2755f
commit 99a93a5da8
5 changed files with 60 additions and 0 deletions

View file

@ -0,0 +1,19 @@
version: '3'
services:
db:
build:
context: ./postgres
ports:
- "5432:5432"
app:
build:
context: ./nodejs
ports:
- "3000:3000"
depends_on:
- db
networks:
- backend
networks:
backend:

View file

@ -0,0 +1,13 @@
FROM node:14
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 3000
CMD [ "npm", "start" ]

View file

@ -0,0 +1,11 @@
const express = require('express');
const app = express();
const port = 3000;
app.get('/', (req, res) => {
res.send('Hello World!');
});
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`);
});

View file

@ -0,0 +1,12 @@
{
"name": "nodejs-express-example",
"version": "1.0.0",
"description": "A simple NodeJS app using Express",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"dependencies": {
"express": "^4.17.1"
}
}

View file

@ -0,0 +1,5 @@
FROM postgres:12
ENV POSTGRES_DB mydb
ENV POSTGRES_USER myuser
ENV POSTGRES_PASSWORD mypassword